home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / libdwarf / libdwarf2.1.mm < prev    next >
Encoding:
Text File  |  1994-08-02  |  123.2 KB  |  3,498 lines

  1. \."
  2. \." the following line may be removed if the ff ligature works on your machine
  3. .lg 0
  4. \." set up heading formats
  5. .ds HF 3 3 3 3 3 2 2
  6. .ds HP +2 +2 +1 +0 +0
  7. .nr Hs 5
  8. .nr Hb 5
  9. .ds | |
  10. .ds ~ ~
  11. .ds ' '
  12. .if t .ds Cw \&\f(CW
  13. .if n .ds Cw \fB
  14. .de Cf          \" Place every other arg in Cw font, beginning with first
  15. .if \\n(.$=1 \&\*(Cw\\$1\fP
  16. .if \\n(.$=2 \&\*(Cw\\$1\fP\\$2
  17. .if \\n(.$=3 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP
  18. .if \\n(.$=4 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4
  19. .if \\n(.$=5 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP
  20. .if \\n(.$=6 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6
  21. .if \\n(.$=7 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP
  22. .if \\n(.$=8 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8
  23. .if \\n(.$=9 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8\
  24. *(Cw
  25. ..
  26. .SA 1
  27. .TL
  28. A Consumer Library Interface to DWARF 
  29. .AF ""
  30. .AU "UNIX\(rg International Programming Languages Special Interest Group" 
  31. .PF "'$Revision: 1.26 $'- \\\\nP -'$Date: 1994/06/20 18:53:17 $'"
  32. .PM ""
  33. .AS 1
  34. This document describes an interface to a library of functions
  35. .FS \(rg
  36. UNIX is a registered trademark of UNIX System Laboratories, Inc.
  37. in the United States and other countries.
  38. .FE
  39. to access DWARF debugging information entries and DWARF line number
  40. information. It does not make recommendations as to how the functions
  41. described in this document should be implemented nor does it
  42. suggest possible optimizations. 
  43. .P
  44. The document is oriented to reading DWARF version 2.
  45. There are certain sections which are SGI-specific (those
  46. are clearly identified in the document).
  47. We intend to propose this 
  48. to the PLSIG committee
  49. as the basis for a
  50. standard libdwarf interface.
  51. .P
  52. The proposals made in this document are subject to change.
  53. .P
  54. $Revision: 1.26 $
  55. .P
  56. $Date: 1994/06/20 18:53:17 $
  57.  
  58. .AE
  59. .MT 4
  60.  
  61. .H 1 "INTRODUCTION"
  62. This document describes the proposed interface to \fIlibdwarf\fP, a
  63. library of functions to provide access to DWARF debugging information
  64. records, DWARF line number information, DWARF address range and global 
  65. names information, weak names information, DWARF frame description 
  66. information, DWARF static function names, DWARF static variables, and 
  67. DWARF type information.
  68. .P
  69.  
  70. .H 2 "Purpose and Scope"
  71. The purpose of this document is to propose a library of functions 
  72. to access DWARF debugging information. There is no effort made in 
  73. this document to address the creation of these records as those
  74. issues will be addressed seperately.
  75.  
  76. .P
  77. Additionally, the focus of this document is the functional interface,
  78. and as such, implementation as well as optimization issues are
  79. intentionally ignored.
  80.  
  81. .H 2 "Definitions"
  82. DWARF debugging information entries (DIE) are the segments of information 
  83. placed in the \f(CW.debug_*\fP sections by compilers, assemblers, and 
  84. linkage editors that, in conjunction with line number entries, are 
  85. necessary for symbolic source-level debugging.  Refer to the document 
  86. "\fIDWARF Debugging Information Format\fP" from UI PLSIG for a more 
  87. complete description of these entries.
  88.  
  89. .P
  90. This document adopts all the terms and definitions in "\fIDWARF Debugging 
  91. Information Format\fP" version 2.  It focuses on the implementation at
  92. Silicon Graphics Computer Systems.  Although we believe the interface
  93. is general enough to be of interest to other vendors too, there are a
  94. few places where changes may need to be made.
  95.  
  96. .H 2 "Overview"
  97. The remaining sections of this document describe the proposed interface
  98. to \f(CWlibdwarf\fP, first by describing the purpose of additional types
  99. defined by the interface, followed by descriptions of the available 
  100. operations.  This document assumes you are thoroughly familiar with the 
  101. information contained in the \fIDWARF Debugging Information Format\fP 
  102. document. 
  103. .P
  104. We separate the functions into several categories to emphasize that not 
  105. all consumers want to use all the functions.  We call the categories 
  106. Debugger, Internal-level, High-level, and Miscellaneous not because one is more 
  107. important than another but as a way of making the rather large set of 
  108. function calls easier to understand.
  109. .P
  110. Unless otherwise specified, all functions and structures should be
  111. taken as being designed for Debugger consumers.
  112. .P
  113. The Debugger Interface of this library is intended to be used by debuggers. 
  114. The interface is low-level (close to dwarf) but suppresses irrelevant detail.
  115. A debugger will want to absorb all of some sections at startup and will 
  116. want to see little or nothing of some sections except at need.  And even 
  117. then will probably want to absorb only the information in a single compilation 
  118. unit at a time.  A debugger does not care about
  119. implementation details of the library.
  120. .P
  121. The Internal-level Interface is for a DWARF prettyprinter and checker.  
  122. thorough prettyprinter will want to know all kinds of internal things 
  123. (like actual FORM numbers and actual offsets) so it can check for 
  124. appropriate structure in the DWARF data and print (on request) all 
  125. that internal information for human users and libdwarf authors and 
  126. compiler-writers.  
  127. Calls in this interface provide data a debugger 
  128. does not care about.
  129. .P
  130. The High-level Interface is for higher level access
  131. (it's not really a high level interface!).  
  132. Programs such as 
  133. disassemblers will want to be able to display relevant information 
  134. about functions and line numbers without having to invest too much 
  135. effort in looking at DWARF.
  136. .P
  137. The miscellaneous interface is just what is left over: the error handler 
  138. functions.
  139. .P
  140. The following is a brief mention of the changes in this libdwarf from 
  141. the libdwarf draft for DWARF Version 1.
  142. .H 2 "Items Changed"
  143. dwarf_nextglob(), dwarf_globname(), and dwarf_globdie() were all changed 
  144. to operate on the items in the .debug_pubnames section.
  145. .P
  146. All functions were modified to return solely an error code.
  147. Data is returned through pointer arguments.
  148. This makes writing safe and correct library-using-code far easier.
  149. For justification for this approach, see the book by
  150. Steve Maguire titled "Writing Solid Code" at your bookstore.
  151.  
  152.  
  153. .H 2 "Items Removed"
  154. .P
  155. Dwarf_Type
  156. was removed since types are no longer special.
  157. .P
  158. dwarf_typeof()
  159. was removed since types are no longer special.
  160. .P
  161. Dwarf_Ellist
  162. was removed since element lists no longer are a special format.
  163. .P
  164. Dwarf_Bounds
  165. was removed since bounds have been generalized.
  166. .P
  167. dwarf_nextdie()
  168. was replaced by dwarf_next_cu_header() to reflect the
  169. real way dwarf is organized.
  170. The dwarf_nextdie() was only useful for getting to compilation
  171. unit beginnings, so it does not seem harmful to remove it in favor
  172. of a more direct function.
  173. .P
  174. dwarf_childcnt() is removed on grounds
  175. that no good use was apparent.
  176. .P
  177. dwarf_prevline() and dwarf_nextline() were removed on grounds this
  178. is better left to a debugger to do.
  179. Similarly, dwarf_dieline() was removed.
  180. .P
  181. dwarf_is1stline() was removed as it was not meaningful for the
  182. revised dwarf line operations.
  183. .P
  184. Any libdwarf implementation might well decide to support all the
  185. removed functionality and to retain the DWARF Version 1 meanings
  186. of that functionality.  
  187. This would be difficult because the
  188. original libdwarf draft
  189. specification used traditional C library interfaces which
  190. confuse the values returned by successful calls with
  191. exceptional conditions like failures and 'no more data' indications.
  192.  
  193. .H 2 "Revision History"
  194. .VL 15
  195. .LI "March 93"
  196. Work on dwarf2 SGI draft begins
  197. .LI "June 94"
  198. The function returns are changed to return an error/success code
  199. only.
  200. .LE
  201.  
  202. .H 1 "Types Definitions"
  203.  
  204. .H 2 "General Description"
  205. The \fIlibdwarf.h\fP header file contains typedefs and preprocessor 
  206. definitions of types and symbolic names used to reference objects 
  207. of \fIlibdwarf\fP. The types defined by typedefs contained in 
  208. \fIlibdwarf.h\fP all use the convention of adding \f(CWDwarf_\fP 
  209. as a prefix and can be placed in three categories: 
  210.  
  211. .BL
  212. .LI
  213. Scalar types : The scalar types defined in \fIlibdwarf.h\fP are
  214. defined primarily for notational convenience and identification.
  215. Depending on the individual definition, they are interpreted as a 
  216. value, a pointer, or as a flag.
  217. .LI
  218. Aggregate types : Some values can not be represented by a single 
  219. scalar type; they must be represented by a collection of, or as a 
  220. union of, scalar and/or aggregate types. 
  221. .LI
  222. Opaque types : The complete definition of these types is intentionally
  223. omitted; their use is as handles for query operations, which will yield
  224. either an instance of another opaque type to be used in another query, or 
  225. an instance of a scalar or aggregate type, which is the actual result.
  226. .P
  227.  
  228. .H 2 "Scalar Types"
  229. The following are the defined by \fIlibdwarf.h\fP:
  230.  
  231. .DS
  232. \f(CW
  233. typedef int                Dwarf_Bool;
  234. typedef unsigned long long Dwarf_Off;
  235. typedef unsigned long long Dwarf_Unsigned;
  236. typedef unsigned short     Dwarf_Half;
  237. typedef unsigned char      Dwarf_Small;
  238. typedef signed long long   Dwarf_Signed;
  239. typedef unsigned long long Dwarf_Addr;
  240. typedef void            *Dwarf_Ptr;
  241. typedef void   (*Dwarf_Handler)(Dwarf_Error *error, Dwarf_Ptr errarg);
  242. .DE
  243.  
  244. .nr aX \n(Fg+1
  245. Dwarf_Ptr is an address for use by the host program calling the library,
  246. not for representing pc-values/addresses within the target object file.
  247. Dwarf_Addr is for pc-values within the target object file.  The sample 
  248. scalar type assignments above are for a \fIlibdwarf.h\fP that can read 
  249. and write
  250. 32-bit or 64-bit binaries on a 32-bit or 64-bit host machine.
  251. The types must be  defined appropriately
  252. for each implementation of libdwarf.
  253. A description of these scalar types in the SGI/MIPS
  254. environment is given in Figure \n(aX.
  255.  
  256. .DS
  257. .TS
  258. center box, tab(:);
  259. lfB lfB lfB lfB
  260. l c c l.
  261. NAME:SIZE:ALIGNMENT:PURPOSE
  262. _
  263. Dwarf_Bool:4:4:Boolean states
  264. Dwarf_Off:8:8:Unsigned file offset
  265. Dwarf_Unsigned:8:8:Unsigned large integer
  266. Dwarf_Half:2:2:Unsigned medium integer
  267. Dwarf_Small:1:1:Unsigned small integer
  268. Dwarf_Signed:8:8:Signed large integer
  269. Dwarf_Addr:8:8:Program address (target program)
  270. Dwarf_Ptr:4|8:4|8:Dwarf section pointer (host program)
  271. Dwarf_Handler:4|8:4|8:Pointer to libdwarf error handler 
  272. :::error handler function 
  273. .TE
  274. .FG "Scalar Types"
  275. .DE
  276.  
  277. .H 2 "Aggregate Types"
  278. The following aggregate types are defined by 
  279. the SGI 
  280. \fIlibdwarf.h\fP:
  281. \f(CWDwarf_Loc\fP,
  282. \f(CWDwarf_Locdesc\fP,
  283. \f(CWDwarf_Block\fP, 
  284. \f(CWDwarf_Frame_Op\fP. 
  285. While most of \f(CWlibdwarf\fP acts on or returns simple values or
  286. opaque pointer types, this small set of structures seems useful.
  287.  
  288. .H 3 "Location Record"
  289. The \f(CWDwarf_Loc\fP type identifies a single atom of a location description
  290. or a location expression.
  291.  
  292. .DS
  293. \f(CWtypedef struct {
  294.         Dwarf_Small        lr_atom;
  295.         Dwarf_Unsigned     lr_number;
  296.         Dwarf_Unsigned     lr_number2;
  297.         Dwarf_Unsigned     lr_offset;  
  298. } Dwarf_Loc;\fP
  299. .DE
  300.  
  301. The \f(CWlr_atom\fP identifies the atom corresponding to the \f(CWDW_OP_*\fP 
  302. definition in \fIdwarf.h\fP and it represents the operation to be performed 
  303. in order to locate the item in question.
  304.  
  305. .P
  306. The \f(CWlr_number\fP field is the operand to be used in the calculation
  307. specified by the \f(CWlr_atom\fP field; not all atoms use this field.
  308. Some atom operations imply signed numbers so it is necessary to cast 
  309. this to a \f(CWDwarf_Signed\fP type for those operations.
  310.  
  311. .P
  312. The \f(CWlr_number2\fP field is the second operand specified by the 
  313. \f(CWlr_atom\fP field; only \f(CWDW_OP_BREGX\fP has this field.  Some 
  314. atom operations imply signed numbers so it may be necessary to cast 
  315. this to a \f(CWDwarf_Signed\fP type for those operations.
  316.  
  317. .P
  318. The \f(CWlr_offset\fP field is the byte offset (within the block the 
  319. location record came from) of the atom specified by the \f(CWlr_atom\fP 
  320. field.  This is set on all atoms.  This is useful for operations 
  321. \f(CWDW_OP_SKIP\fP and \f(CWDW_OP_BRA\fP.
  322.  
  323. .H 3 "Location Description"
  324. The \f(CWDwarf_Locdesc\fP type represents an ordered list of 
  325. \f(CWDwarf_Loc\fP records used in the calculation to locate 
  326. an item.  Note that in many cases, the location can only be 
  327. calculated at runtime of the associated program.
  328.  
  329. .DS
  330. \f(CWtypedef struct {
  331.         Dwarf_Addr        ld_lopc;
  332.         Dwarf_Addr        ld_hipc;
  333.         Dwarf_Unsigned    ld_cents;
  334.         Dwarf_Loc*        ld_s;
  335. } Dwarf_Locdesc;\fP
  336. .DE
  337.  
  338. The \f(CWld_lopc\fP and \f(CWld_hipc\fP fields provide an address range for
  339. which this location descriptor is valid.  Both of these fields are set to
  340. \fIzero\fP if the location descriptor is valid throughout the scope of the
  341. item it is associated with.  These addresses are virtual memory addresses, 
  342. not offsets-from-something.  The virtual memory addresses do not account 
  343. for dso movement (none of the pc values from libdwarf do that, it is up to 
  344. the consumer to do that).
  345.  
  346. .P
  347. The \f(CWld_cents\fP field contains a count of the number of \f(CWDwarf_Loc\fP 
  348. entries pointed to by the \f(CWld_s\fP field.
  349.  
  350. .P
  351. The \f(CWld_s\fP field points to an array of \f(CWDwarf_Loc\fP records. 
  352.  
  353. .H 3 "Data Block"
  354. .SP
  355. The \f(CWDwarf_Block\fP type is used to contain the value of an attribute
  356. whose form is either \f(CWDW_FORM_block1\fP, \f(CWDW_FORM_block2\fP, 
  357. \f(CWDW_FORM_block4\fP, \f(CWDW_FORM_block8\fP, or \f(CWDW_FORM_block\fP.
  358. Its intended use is to deliver the value for an attribute of any of these 
  359. forms.
  360.  
  361. .DS
  362. \f(CWtypedef struct {
  363.         Dwarf_Unsigned     bl_len;
  364.         Dwarf_Ptr          bl_data;
  365. } Dwarf_Block;\fP
  366. .DE
  367.  
  368. .P
  369. The \f(CWbl_len\fP field contains the length in bytes of the data pointed
  370. to by the \f(CWbl_data\fP field. 
  371.  
  372. .P
  373. The \f(CWbl_data\fP field contains a pointer to the uninterpreted data.
  374. Since we use  a \f(CWDwarf_Ptr\fP here one must copy the pointer to some 
  375. other type (typically an \f(CWunsigned char *\fP) so one can add increments 
  376. to index through the data.  The data pointed to by \f(CWbl_data\fP is not 
  377. necessarily at any useful alignment.
  378.  
  379. .H 3 "Frame Operation Codes"
  380. The \f(CWDwarf_Frame_Op\fP type is used to contain the data of a single
  381. instruction of an instruction-sequence of low-level information from the 
  382. section containing frame information.  This is ordinarily used by 
  383. Internal-level 
  384. Consumers trying to print everything in detail.
  385.  
  386. .DS
  387. \f(CWtypedef struct {
  388.     Dwarf_Small  fp_base_op;
  389.     Dwarf_Small  fp_extended_op;
  390.     Dwarf_Half   fp_register;
  391.     Dwarf_Signed fp_offset;
  392.     Dwarf_Offset fp_instr_offset;
  393. } Dwarf_Frame_Op;
  394. .DE
  395.  
  396. \f(CWfp_base_op\fP is the 2-bit basic op code.  \f(CWfp_extended_op\fP is 
  397. the 6-bit extended opcode (if \f(CWfp_base_op\fP indicated there was an 
  398. extended op code) and is zero otherwise.
  399. .P
  400. \f(CWfp_register\fP 
  401. is any (or the first) register value as defined
  402. in the \f(CWCall Frame Instruction Encodings\fP figure
  403. in the \f(CWdwarf\fP document.
  404. If not used with the Op it is 0.
  405. .P
  406. \f(CWfp_offset\fP
  407. is the address, delta, offset, or second register as defined
  408. in the \f(CWCall Frame Instruction Encodings\fP figure
  409. in the \f(CWdwarf\fP document.
  410. If this is an \f(CWaddress\fP then the value should be cast to
  411. \f(CW(Dwarf_Addr)\fP before being used.
  412. In any implemenation this field *must* be as large as the
  413. larger of Dwarf_Signed and Dwarf_Addr for this to work properly.
  414. If not used with the op it is 0.
  415. .P
  416. \f(CWfp_instr_offset\fP is the byte_offset (within the instruction
  417. stream of the frame instructions) of this operation.  It starts at 0
  418. for a given frame descriptor.
  419.  
  420. .H 2 "Opaque Types"
  421. The opaque types declared in \fIlibdwarf.h\fP are used as descriptors
  422. for queries against dwarf information stored in various debugging 
  423. sections.  Each time an instance of an opaque type is returned as a 
  424. result of a \fIlibdwarf\fP operation (\f(CWDwarf_Debug\fP excepted), 
  425. it should be free'd, using \f(CWdwarf_dealloc()\fP when it is no longer 
  426. of use.  
  427. Some functions return a number of instances of an opaque type 
  428. in a block, by means of a pointer to the block and a count of the number
  429. of opaque descriptors in the block:
  430. see the function description for deallocation rules for such functions.
  431. The list of opaque types defined 
  432. in \fIlibdwarf.h\fP that are pertinent to the Consumer Library, and their 
  433. intended use is described below.
  434.  
  435. .DS
  436. \f(CWtypedef struct Dwarf_Debug_s* Dwarf_Debug;\fP
  437. .DE
  438. An instance of the \f(CWDwarf_Debug\fP type is created as a result of a 
  439. successful call to \f(CWdwarf_init()\fP, or \f(CWdwarf_elf_init()\fP, 
  440. and is used as a descriptor for subsequent access to most \f(CWlibdwarf\fP
  441. functions on that object.  The storage pointed to by this descriptor 
  442. should be not be free'd, using the \f(CWdwarf_dealloc()\fP function.
  443. Instead free it with \f(CWdwarf_finish()\fP.
  444. .P
  445.  
  446. .DS
  447. \f(CWtypedef struct Dwarf_Die_s* Dwarf_Die;\fP
  448. .DE
  449. An instance of a \f(CWDwarf_Die\fP type is returned from a successful 
  450. call to the \f(CWdwarf_siblingof()\fP, \f(CWdwarf_child\fP, or 
  451. \f(CWdwarf_offdie()\fP function, and is used as a descriptor for queries 
  452. about information related to that DIE.  The storage pointed to by this 
  453. descriptor should be free'd, using \f(CWdwarf_dealloc()\fP with the allocation 
  454. type \f(CWDW_DLA_DIE\fP when no longer needed.
  455.  
  456. .DS
  457. \f(CWtypedef struct Dwarf_Line_s* Dwarf_Line;\fP
  458. .DE
  459. Instances of \f(CWDwarf_Line\fP type are returned from a successful call 
  460. to the \f(CWdwarf_srclines()\fP function, and are used as descriptors for 
  461. queries about source lines.  The storage pointed to by these descriptors
  462. should be individually free'd, using \f(CWdwarf_dealloc()\fP with the 
  463. allocation type \f(CWDW_DLA_LINE\fP when no longer needed.
  464.  
  465. .DS
  466. \f(CWtypedef struct Dwarf_Global_s* Dwarf_Global;\fP
  467. .DE
  468. Instances of \f(CWDwarf_Global\fP type are returned from a successful 
  469. call to the \f(CWdwarf_get_globals()\fP function, and are used as 
  470. descriptors for queries about global names (pubnames).  The storage 
  471. pointed to by these descriptors should be individually free'd, using 
  472. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_GLOBAL\fP, 
  473. when no longer needed.
  474.  
  475. .DS
  476. \f(CWtypedef struct Dwarf_Weak_s* Dwarf_Weak;\fP
  477. .DE
  478. Instances of \f(CWDwarf_Weak\fP type are returned from a successful call 
  479. to the 
  480. SGI-specific \f(CWdwarf_get_weaks()\fP
  481. function, and are used as descriptors for 
  482. queries about weak names.  The storage pointed to by these descriptors 
  483. should be individually free'd, using \f(CWdwarf_dealloc()\fP with the 
  484. allocation type \f(CWDW_DLA_WEAK\fP when no longer needed.
  485.  
  486. .DS
  487. \f(CWtypedef struct Dwarf_Func_s* Dwarf_Func;\fP
  488. .DE
  489. Instances of \f(CWDwarf_Func\fP type are returned from a successful
  490. call to the 
  491. SGI-specific \f(CWdwarf_get_funcs()\fP
  492. function, and are used as 
  493. descriptors for queries about static function names.  
  494. The storage 
  495. pointed to by these descriptors should be individually free'd, using 
  496. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_FUNC\fP, 
  497. when no longer needed.
  498.  
  499. .DS
  500. \f(CWtypedef struct Dwarf_Type_s* Dwarf_Type;\fP
  501. .DE
  502. Instances of \f(CWDwarf_Type\fP type are returned from a successful call 
  503. to the 
  504. SGI-specific \f(CWdwarf_get_types()\fP
  505. function, and are used as descriptors for 
  506. queries about user defined types.  
  507. The storage pointed to by this descriptor 
  508. should be individually free'd, using \f(CWdwarf_dealloc()\fP with the 
  509. allocation type \f(CWDW_DLA_TYPENAME\fP when no longer needed.
  510.  
  511. .DS
  512. \f(CWtypedef struct Dwarf_Var_s* Dwarf_Var;\fP
  513. .DE
  514. Instances of \f(CWDwarf_Var\fP type are returned from a successful call 
  515. to the SGI-specfic \f(CWdwarf_get_vars()\fP
  516. function, and are used as descriptors for 
  517. queries about static variables.  
  518. The storage pointed to by this descriptor 
  519. should be individually free'd, using \f(CWdwarf_dealloc()\fP with the 
  520. allocation type \f(CWDW_DLA_VAR\fP when no longer needed.
  521.  
  522. .DS
  523. \f(CWtypedef struct Dwarf_Error_s* Dwarf_Error;\fP
  524. .DE
  525. This descriptor points to a structure that provides detailed information
  526. about errors detected by \f(CWlibdwarf\fP.  Users typically provide a
  527. location for \f(CWlibdwarf\fP to store this descriptor for the user to
  528. obtain more information about the error.  The storage pointed to by this
  529. descriptor should be free'd, using \f(CWdwarf_dealloc()\fP with the 
  530. allocation type \f(CWDW_DLA_ERROR\fP when no longer needed.
  531.  
  532. .DS
  533. \f(CWtypedef struct Dwarf_Attribute_s* Dwarf_Attribute;\fP
  534. .DE
  535. Instances of \f(CWDwarf_Attribute\fP type are returned from a successful 
  536. call to the \f(CWdwarf_attrlist()\fP, or \f(CWdwarf_attr()\fP functions, 
  537. and are used as descriptors for queries about attribute values.  The storage 
  538. pointed to by this descriptor should be individually free'd, using 
  539. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_ATTR\fP when 
  540. no longer needed.
  541.  
  542. .DS
  543. \f(CWtypedef struct Dwarf_Abbrev_s* Dwarf_Abbrev;\fP
  544. .DE
  545. An instance of a \f(CWDwarf_Abbrev\fP type is returned from a successful 
  546. call to \f(CWdwarf_get_abbrev()\fP, and is used as a descriptor for queries 
  547. about abbreviations in the .debug_abbrev section.  The storage pointed to 
  548. by this descriptor should be free'd, using \f(CWdwarf_dealloc()\fP with the
  549. allocation type \f(CWDW_DLA_ABBREV\fP when no longer needed.
  550.  
  551. .DS
  552. \f(CWtypedef struct Dwarf_Fde_s* Dwarf_Fde;\fP
  553. .DE
  554. Instances of \f(CWDwarf_Fde\fP type are returned from a successful call 
  555. to the \f(CWdwarf_get_fde_list()\fP, \f(CWdwarf_get_fde_for_die()\fP, or
  556. \f(CWdwarf_get_fde_at_pc()\fP functions, and are used as descriptors for 
  557. queries about frames descriptors.  The storage pointed to by these 
  558. descriptors should be individually free'd, using \f(CWdwarf_dealloc()\fP 
  559. with the allocation type \f(CWDW_DLA_FDE\fP when no longer needed.
  560.  
  561. .DS
  562. \f(CWtypedef struct Dwarf_Cie_s* Dwarf_Cie;\fP
  563. .DE
  564. Instances of \f(CWDwarf_Cie\fP type are returned from a successful call 
  565. to the \f(CWdwarf_get_fde_list()\fP function, and are used as descriptors 
  566. for queries about information that is common to several frames.  The 
  567. storage pointed to by this descriptor should be individually free'd, using 
  568. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_CIE\fP when 
  569. no longer needed.
  570.  
  571. .DS
  572. \f(CWtypedef struct Dwarf_Arange_s* Dwarf_Arange;\fP
  573. .DE
  574. Instances of \f(CWDwarf_Arange\fP type are returned from successful calls 
  575. to the \f(CWdwarf_get_aranges()\fP, or \f(CWdwarf_get_arange()\fP functions, 
  576. and are used as descriptors for queries about address ranges.  The storage 
  577. pointed to by this descriptor should be individually free'd, using 
  578. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_ARANGE\fP when 
  579. no longer needed.
  580.  
  581. .\"#if 0
  582. .\".DS
  583. .\"\f(CWtypedef struct Dwarf_Macro_Info* Dwarf_Macro_Info;\fP
  584. .\".DE
  585. .\"A pointer to an array of \f(CWDwarf_Macro_Info\fP pointers is returned 
  586. .\"from a successfull call to \f(CWdwarf_get_macinfo\fP and is used as a 
  587. .\"descriptor for queries concerning C-style macros.  This struct is
  588. .\"currently undefined.
  589. .\"#endif
  590.  
  591. .H 1 "Error Handling"
  592. The method for detection and disposition of error conditions that arise 
  593. during access of debugging information via \fIlibdwarf\fP is consistent
  594. across all \fIlibdwarf\fP functions that are capable of producing an
  595. error.  This section describes the method used by \fIlibdwarf\fP in
  596. notifying client programs of error conditions. 
  597.  
  598. .P
  599. Most functions within \fIlibdwarf\fP accept as an argument a pointer to 
  600. a \f(CWDwarf_Error\fP descriptor where a \f(CWDwarf_Error\fP descriptor 
  601. is stored if an error is detected by the function.  Routines in the client 
  602. program that provide this argument can query the \f(CWDwarf_Error\fP 
  603. descriptor to determine the nature of the error and perform appropriate 
  604. processing. 
  605.  
  606. .P
  607. A client program can also specify a function to be invoked upon detection 
  608. of an error at the time the library is initialized (see \f(CWdwarf_init()\fP). 
  609. When a \fIlibdwarf\fP routine detects an error, this function is called
  610. with two arguments: a code indicating the nature of the error and a pointer
  611. provided by the client at initialization (again see \f(CWdwarf_init()\fP).
  612. This pointer argument can be used to relay information between the error 
  613. handler and other routines of the client program.  A client program can 
  614. specify or change both the error handling function and the pointer argument 
  615. after initialization using \f(CWdwarf_seterrhand()\fP and 
  616. \f(CWdwarf_seterrarg()\fP.
  617.  
  618. .P
  619. In the case where \fIlibdwarf\fP functions are not provided a pointer
  620. to a \f(CWDwarf_Error\fP descriptor, and no error handling function was 
  621. provided at initialization, \fIlibdwarf\fP functions terminate execution 
  622. by calling \f(CWabort(3C)\fP.
  623.  
  624. .P
  625. The following lists the processing steps taken upon detection of an
  626. error:
  627. .AL 1
  628. .LI
  629. Check the \f(CWerror\fP argument; if not a \fINULL\fP pointer, allocate
  630. and initialize a \f(CWDwarf_Error\fP descriptor with information describing
  631. the error, place this descriptor in the area pointed to by \f(CWerror\fP,
  632. and return a value indicating an error condition.
  633. .LI
  634. If an \f(CWerrhand\fP argument was provided to \f(CWdwarf_init()\fP
  635. at initialization, call \f(CWerrhand()\fP passing it the error descriptor
  636. and the value of the \f(CWerrarg\fP argument provided to \f(CWdwarf_init()\fP. 
  637. If the error handling function returns, return a value indicating an 
  638. error condition.
  639. .LI
  640. Terminate program execution by calling \f(CWabort(3C)\fP.
  641. .LE
  642. .SP
  643.  
  644. In all cases, it is clear from the value returned from a function 
  645. that an error occured in executing the function, since
  646. DW_DLV_ERROR is returned.
  647. .P
  648. As can be seen from the above steps, the client program can provide
  649. an error handler at initialization, and still provide an \f(CWerror\fP
  650. argument to \fIlibdwarf\fP functions when it is not desired to have
  651. the error handler invoked.
  652.  
  653. .P
  654. If a \f(CWlibdwarf\fP function is called with invalid arguments, the 
  655. behaviour is undefined.  In particular, supplying a \f(CWNULL\fP pointer 
  656. to a \f(CWlibdwarf\fP function (except where explicitely permitted), 
  657. or pointers to invalid addresses or uninitialized data causes undefined 
  658. behaviour; the return value in such cases is undefined, and the function 
  659. may fail to invoke the caller supplied error handler or to return a 
  660. meaningful error number.  Implementations also may abort execution for 
  661. such cases.
  662.  
  663. .P
  664. .H 2 "Returned values in the functional interface"
  665. Values returned by \f(CWlibdwarf\fP functions to indicate 
  666. success and errors
  667. .nr aX \n(Fg+1
  668. are enumerated in Figure \n(aX.
  669. The \f(CWDW_DLV_NO_ENTRY\fP
  670. case is useful for functions 
  671. need to indicate that while there was no data to return
  672. there was no error either.
  673. For example, \f(CWdwarf_siblingof()\fP
  674. may return \f(CWDW_DLV_NO_ENTRY\fP to indicate that that there was
  675. no sibling to return.
  676. .DS
  677. .TS
  678. center box, tab(:);
  679. lfB cfB lfB 
  680. l c l.
  681. SYMBOLIC NAME:VALUE:MEANING
  682. _
  683. DW_DLV_ERROR:1:Error
  684. DW_DLV_OK:0:Successful call
  685. DW_DLV_NO_ENTRY:-1:No applicable value
  686. .TE
  687. .FG "Error Indications"
  688. .DE
  689. .P
  690. Each function in the interface that returns a value returns one
  691. of the integers in the above figure.
  692. .P
  693. If \f(CWDW_DLV_ERROR\fP is returned and a pointer to a \f(CWDwarf_Error\fP
  694. pointer is passed to the function, then a Dwarf_Error handle is returned
  695. thru the pointer. No other pointer value in the interface returns a value.
  696. .P
  697. If \f(CWDW_DLV_NO_ENTRY\fP is returned no pointer value in the
  698. interface returns a value.
  699. .P
  700. If \f(CWDW_DLV_NO_OK\fP is returned  the \f(CWDwarf_Error\fP pointer, if
  701. supplied, is not touched, but any other values to be returned
  702. through pointers are returned.
  703. .P
  704. Pointers passed to allow values to be returned thru them are 
  705. uniformly the last pointers
  706. in each argument list.
  707. .P
  708. All the interface functions are defined from the point of view of
  709. the writer-of-the-library (as is traditional for UN*X library
  710. documentation), not from the point of view of the user of the library.
  711. The caller might code:
  712. .P
  713. .DS
  714. Dwarf_Line line;
  715. Dwarf_Signed ret_loff;
  716. Dwarf_Error  err;
  717. int retval = dwarf_lineoff(line,&ret_loff,&err); 
  718. .DE
  719. for the function defined as
  720. .P
  721. .DS
  722. int dwarf_lineoff(Dwarf_Line line,Dwarf_Signed *return_lineoff,
  723.   Dwarf_Error* err);
  724. .DE
  725. and this document refers to the function as 
  726. returning the value thru *err or *return_lineoff or 
  727. uses the phrase "returns in
  728. the location pointed to by err".
  729. Sometimes other similar phrases are used.
  730.  
  731. .H 1 "Memory Management"
  732. Several of the functions that comprise \fIlibdwarf\fP return pointers 
  733. (opaque descriptors) to structures that have been dynamically allocated 
  734. by the library.  To aid in the management of dynamic memory, the function 
  735. \f(CWdwarf_dealloc()\fP is provided to free storage allocated as a result 
  736. of a call to a \fIlibdwarf\fP function.  This section describes the strategy 
  737. that should be taken by a client program in managing dynamic storage.
  738.  
  739. .H 2 "Read-only Properties"
  740. All pointers (opaque descriptors) returned by or as a result of a 
  741. \fIlibdwarf Consumer Library\fP 
  742. call should be assumed to point to read-only memory.  
  743. The results are undefined for \fIlibdwarf\fP  clients that attempt 
  744. to write to a region pointed to by a value returned by a 
  745. \fIlibdwarf Consumer Library\fP 
  746. call.
  747.  
  748. .H 2 "Storage Deallocation"
  749. In some cases the pointers returned by a \fIlibdwarf\fP call are pointers
  750. to data which is not free-able.  
  751. The library knows from the allocation type
  752. provided to it whether the space is freeable or not and will not free 
  753. inappropriately when \f(CWdwarf_dealloc()\fP is called.  
  754. So it is vital
  755. that \f(CWdwarf_dealloc()\fP be called with the proper allocation type.
  756. .P
  757. For most storage allocated by \fIlibdwarf\fP, the client can free the
  758. storage for reuse by calling \f(CWdwarf_dealloc()\fP, providing it with 
  759. the \f(CWDwarf_Debug\fP descriptor sepcifying the object for which the
  760. storage was allocated, a pointer to the area to be free-ed, and an 
  761. identifier that specifies what the pointer points to (the allocation
  762. type).  For example, to free a \f(CWDwarf_Die die\fP belonging the the
  763. object represented by \f(CWDwarf_Debug dbg\fP, allocated by a call to 
  764. \f(CWdwarf_siblingof()\fP, the call to \f(CWdwarf_dealloc()\fP would be:
  765. .DS
  766.     \f(CWdwarf_dealloc(dbg, die, DW_DLA_DIE);\fP
  767. .DE
  768.  
  769. To free storage allocated in the form of a list of pointers (opaque 
  770. descriptors), each member of the list should be deallocated, followed 
  771. by deallocation of the actual list itself.  The following code fragment 
  772. uses an invocation of \f(CWdwarf_attrlist()\fP as an example to illustrate 
  773. a technique that can be used to free storage from any \fIlibdwarf\fP 
  774. routine that returns a list:
  775. .DS
  776. \f(CWDwarf_Unsigned atcnt;
  777. Dwarf_Attribute *atlist;
  778. int errv;
  779.  
  780. if ((errv = dwarf_attrlist(somedie, &atlist,&atcnt, &error)) == DW_DLV_OK) {
  781.  
  782.         for (i = 0; i < atcnt; ++i) {
  783.                 /* use atlist[i] */
  784.                 dwarf_dealloc(dbg, atlist[i], DW_DLA_ATTR);
  785.         }
  786.         dwarf_dealloc(dbg, atlist, DW_DLA_LIST);
  787. }\fP
  788. .DE
  789.  
  790. The \f(CWDwarf_Debug\fP returned from \f(CWdwarf_init()\fP is the only
  791. dynamic storage that cannot be free'd, using \f(CWdwarf_dealloc()\fP.
  792. The function \f(CWdwarf_finish()\fP will deallocate all dynamic storage
  793. associated with an instance of a \f(CWDwarf_Debug\fP type.  In particular,
  794. it will deallocate all dynamically allocated space associated with the
  795. \f(CWDwarf_Debug\fP descriptor, and finally make the descriptor invalid.
  796.  
  797. .P
  798. The codes that identify the storage pointed to in calls to 
  799. .nr aX \n(Fg+1
  800. \f(CWdwarf_dealloc()\fP are described in figure \n(aX.
  801. .DS
  802. .TS
  803. center box, tab(:);
  804. lfB lfB 
  805. l l.
  806. IDENTIFIER:USED TO FREE 
  807. _
  808. DW_DLA_STRING           :     char* 
  809. DW_DLA_LOC              :     Dwarf_Loc 
  810. DW_DLA_LOCDESC          :     Dwarf_Locdesc 
  811. DW_DLA_ELLIST           :     Dwarf_Ellist (not used)
  812. DW_DLA_BOUNDS           :     Dwarf_Bounds (not used) 
  813. DW_DLA_BLOCK            :     Dwarf_Block 
  814. DW_DLA_DEBUG            :     Dwarf_Debug
  815. DW_DLA_DIE              :     Dwarf_Die
  816. DW_DLA_LINE             :     Dwarf_Line 
  817. DW_DLA_ATTR             :     Dwarf_Attribute 
  818. DW_DLA_TYPE             :     Dwarf_Type  (not used) 
  819. DW_DLA_SUBSCR           :     Dwarf_Subscr (not used) 
  820. DW_DLA_GLOBAL           :     Dwarf_Global 
  821. DW_DLA_ERROR            :     Dwarf_Error 
  822. DW_DLA_LIST             :     a list of opaque descriptors
  823. DW_DLA_LINEBUF          :     Dwarf_Line* (not used) 
  824. DW_DLA_ARANGE           :     Dwarf_Arange 
  825. DW_DLA_ABBREV           :     Dwarf_Abbrev 
  826. DW_DLA_FRAME_OP         :     Dwarf_Frame_Op 
  827. DW_DLA_CIE              :     Dwarf_Cie 
  828. DW_DLA_FDE              :     Dwarf_Fde
  829. DW_DLA_LOC_BLOCK        :     Dwarf_Loc Block
  830. DW_DLA_FRAME_BLOCK      :     Dwarf_Frame Block (not used) 
  831. DW_DLA_FUNC             :     Dwarf_Func 
  832. DW_DLA_TYPENAME         :     Dwarf_Type
  833. DW_DLA_VAR              :     Dwarf_Var
  834. DW_DLA_WEAK        :     Dwarf_Weak
  835. .TE
  836. .FG "Allocation/Deallocation Identifiers"
  837. .DE
  838.  
  839. .P
  840. .H 1 "Functional Interface"
  841. This section describes the functions available in the \fIlibdwarf\fP
  842. library.  Each function description includes its definition, followed 
  843. by one or more paragraph describing the function's operation.
  844.  
  845. .P
  846. The following sections describe these functions.
  847.  
  848. .H 2 "Initialization Operations"
  849. These functions are concerned with preparing an object file for subsequent
  850. access by the functions in \fIlibdwarf\fP and with releasing allocated
  851. resources when access is complete. 
  852.  
  853. .DS
  854. \f(CWint dwarf_init(
  855.         int fd,
  856.         Dwarf_Unsigned access,
  857.         Dwarf_Handler errhand, 
  858.         Dwarf_Ptr errarg,
  859.     Dwarf_Debug * dbg,
  860.         Dwarf_Error *error)\fP
  861. .DE
  862. When it returns \f(CWDW_DLV_OK\fP,
  863. the function \f(CWdwarf_init()\fP returns  thru
  864. \f(CWdbg\fP a \f(CWDwarf_Debug\fP descriptor 
  865. that represents a handle for accessing debugging records associated with 
  866. the open file descriptor \f(CWfd\fP.  
  867. \f(CWDW_DLV_ERROR\fP is returned if the object 
  868. does not contain debugging information or an error occurred.  
  869. The 
  870. \f(CWaccess\fP argument indicates what access is allowed for the section. 
  871. The \f(CWDW_DLC_READ\fP parameter is valid
  872. for read access (only read access is defined or discussed in this
  873. document).  
  874. The \f(CWerrhand\fP 
  875. argument is a pointer to a function that will be invoked whenever an error 
  876. is detected as a result of a \fIlibdwarf\fP operation.  The \f(CWerrarg\fP 
  877. argument is passed as an argument to the \f(CWerrhand\fP function.  
  878. The file 
  879. descriptor associated with the \f(CWfd\fP argument must refer to an ordinary 
  880. file (i.e. not a pipe, socket, device, /proc entry, etc.), be opened with 
  881. the at least as much permission as specified by the \f(CWaccess\fP argument, 
  882. and cannot be closed or used as an argument to any system calls by the 
  883. client until after \f(CWdwarf_finish()\fP is called.  
  884. The seek position of 
  885. the file associated with \f(CWfd\fP is undefined upon return of 
  886. \f(CWdwarf_init()\fP.
  887.  
  888. Since \f(CWdwarf_init()\fP uses the same error handling processing as other 
  889. \fIlibdwarf\fP functions (see \fIError Handling\fP above), client programs 
  890. will generally supply an \f(CWerror\fP parameter to bypass the default actions 
  891. during initialization unless the default actions are appropriate. 
  892.  
  893. .DS
  894. \f(CWint dwarf_elf_init(
  895.         Elf * elf_file_pointer,
  896.         Dwarf_Unsigned access,
  897.         Dwarf_Handler errhand, 
  898.         Dwarf_Ptr errarg,
  899.     Dwarf_Debug * dbg,
  900.         Dwarf_Error *error)\fP
  901. .DE
  902. The function \f(CWdwarf_elf_init()\fP is identical to \f(CWdwarf_init()\fP 
  903. except that an open \f(CWElf *\fP pointer is passed instead of a file 
  904. descriptor.  
  905. In systems supporting \f(CWELF\fP object files this may be 
  906. more space or time-efficient than using \f(CWdwarf_init()\fP.
  907. The client is allowed to use the \f(CWElf *\fP pointer
  908. for its own purposes without restriction during the time the 
  909. \f(CWDwarf_Debug\fP
  910. is open, except that the client should not  \f(CWelf_end()\fP the
  911. pointer till after  \f(CWdwarf_finish\fP is called.
  912.  
  913. .DS
  914. \f(CWint dwarf_get_elf(
  915.         Dwarf_Debug dbg,
  916.         Elf **      elf,
  917.         Dwarf_Error *error)\fP
  918. .DE
  919. When it returns \f(CWDW_DLV_OK\fP,
  920. the function \f(CWdwarf_get_elf()\fP returns thru the
  921. pointer \f(CWelf\fP the \f(CWElf *\fP handle
  922. used to access the object represented by the \f(CWDwarf_Debug\fP
  923. descriptor \f(CWdbg\fP.  It returns \f(CWDW_DLV_ERROR\fP on error.
  924.  
  925. This function is not meaningful for a system that does not used the
  926. Elf format for objects.
  927.  
  928. .DS
  929. \f(CWint dwarf_finish(
  930.         Dwarf_Debug dbg,
  931.     Dwarf_Error *error)\fP
  932. .DE
  933. The function
  934. \f(CWdwarf_finish()\fP releases all \fILibdwarf\fP internal resources 
  935. associated with the descriptor \f(CWdbg\fP, and invalidates \f(CWdbg\fP.  
  936. It returns \f(CWDW_DLV_ERROR\fP if there is an error during the
  937. finishing operation.  It returns \f(CWDW_DLV_OK\fP 
  938. for a successful operation.
  939.  
  940. .H 2 "Debugging Information Entry Delivery Operations"
  941. These functions are concerned with accessing debugging information 
  942. entries. 
  943.  
  944. .H 3 "Debugging Information Entry Debugger Delivery Operations"
  945.  
  946. .DS
  947. \f(CWint dwarf_next_cu_header(
  948.         Dwarf_debug dbg,
  949.         Dwarf_Unsigned *cu_header_length,
  950.         Dwarf_Half     *version_stamp,
  951.         Dwarf_Unsigned *abbrev_offset,
  952.         Dwarf_Half     *address_size,
  953.         Dwarf_Unsigned *next_cu_header,
  954.         Dwarf_Error    *error);
  955. .DE
  956. The function
  957. \f(CWdwarf_next_cu_header()\fP returns \f(CWDW_DLV_ERROR\fP 
  958. if it fails, and
  959. \f(CWDW_DLV_OK\fP if it succeeds.
  960. .P
  961. If it succeeds, \f(CW*next_cu_header\fP is set to
  962. the offset in the .debug_info section of the next 
  963. compilation-unit header if it succeeds.  On reading the last 
  964. compilation-unit header in the .debug_info section it contains 
  965. the size of the .debug_info section.
  966. The next call to 
  967. \f(CWdwarf_next_cu_header()\fP returns \f(CWDW_DLV_NO_ENTRY\fP
  968. without reading a 
  969. compilation-unit or setting \f(CW*next_cu_header\fP.  
  970. Subsequent calls to \f(CWdwarf_next_cu_header()\fP 
  971. repeat the cycle by reading the first compilation-unit and so on.  
  972. .P
  973. The other 
  974. values returned through pointers are the values in the compilation-unit 
  975. header.  If any of \f(CWcu_header_length\fP, \f(CWversion_stamp\fP,
  976. \f(CWabbrev_offset\fP, or \f(CWaddress_size\fP is \f(CWNULL\fP, the 
  977. argument is ignored (meaning it is not an error to provide a 
  978. \f(CWNULL\fP pointer).
  979.  
  980. .DS
  981. \f(CWint dwarf_siblingof(
  982.         Dwarf_Debug dbg, 
  983.         Dwarf_Die die, 
  984.     Dwarf_Die *return_sib,
  985.         Dwarf_Error *error)\fP
  986. .DE
  987. The function \f(CWdwarf_siblingof()\fP 
  988. returns \f(CWDW_DLV_ERROR\fP and sets the \f(CWerror\fP pointer on error.
  989. If there is no sibling it returns \f(CWDW_DLV_NO_ENTRY\fP.
  990. When it succeeds,
  991. \f(CWdwarf_siblingof()\fP returns
  992. \f(CWDW_DLV_OK\fP  and sets \f(CW*return_sib\fP to the \f(CWDwarf_Die\fP 
  993. descriptor of the sibling of \f(CWdie\fP.
  994. If \f(CWdie\fP is \fINULL\fP, the \f(CWDwarf_Die\fP descriptor of the
  995. first die in the compilation-unit is returned.  
  996. This die has the
  997. \f(CWDW_TAG_compile_unit\fP tag.
  998.  
  999. .DS
  1000. \f(CWint dwarf_child(
  1001.         Dwarf_Die die, 
  1002.     Dwarf_Die *return_kid,
  1003.         Dwarf_Error *error)\fP
  1004. .DE
  1005. The function \f(CWdwarf_child()\fP 
  1006. returns \f(CWDW_DLV_ERROR\fP and sets the \f(CWerror\fP die on error.
  1007. If there is no child it returns \f(CWDW_DLV_NO_ENTRY\fP.
  1008. When it succeeds,
  1009. \f(CWdwarf_child()\fP returns 
  1010. \f(CWDW_DLV_OK\fP and sets \f(CW*return_kid\fP
  1011. to the \f(CWDwarf_Die\fP descriptor 
  1012. of the first child of \f(CWdie\fP.
  1013. The function 
  1014. \f(CWdwarf_siblingof()\fP can be used with the return value of 
  1015. \f(CWdwarf_child()\fP to access the other children of \f(CWdie\fP. 
  1016.  
  1017. .DS
  1018. \f(CWint dwarf_offdie(
  1019.         Dwarf_Debug dbg,
  1020.         Dwarf_Off offset, 
  1021.     Dwarf_Die *return_die,
  1022.         Dwarf_Error *error)\fP
  1023. .DE
  1024. The function \f(CWdwarf_child()\fP 
  1025. returns \f(CWDW_DLV_ERROR\fP and sets the \f(CWerror\fP die on error.
  1026. When it succeeds,
  1027. \f(CWdwarf_offdie()\fP returns
  1028. \f(CWDW_DLV_OK\fP and sets \f(CW*return_die\fP
  1029. to the
  1030. the \f(CWDwarf_Die\fP 
  1031. descriptor of the debugging information entry at \f(CWoffset\fP in 
  1032. the section containing debugging information entries i.e the .debug_info
  1033. section.  
  1034. It is the user's 
  1035. responsibility to make sure that \f(CWoffset\fP is the start of a valid 
  1036. debugging information entry.  The result of passing it an invalid 
  1037. offset could be chaos.
  1038.  
  1039. .\"#if 0
  1040. .\".H 3 "Debugging Entry Delivery High-level Operations"
  1041. .\"The following "higher level" operations are typically not used by 
  1042. .\"debuggers or DWARF prettyprinters.  A disassembler (for example) 
  1043. .\"might find them useful.
  1044. .\"
  1045. .\".DS
  1046. .\"\f(CWDwarf_Die dwarf_pcfile(
  1047. .\"        Dwarf_Debug dbg, 
  1048. .\"        Dwarf_Addr pc, 
  1049. .\"        Dwarf_Error *error)\fP
  1050. .\".DE
  1051. .\"The function \f(CWdwarf_pcfile()\fP returns the \f(CWDwarf_Die\fP 
  1052. .\"descriptor of the compilation unit debugging information entry that 
  1053. .\"contains the address of \f(CWpc\fP.  It returns \fINULL\fP if no 
  1054. .\"entry exists or an error occurred.  Currently compilation unit 
  1055. .\"debugging information entries are defined as those having a tag of: 
  1056. .\"\f(CWDW_TAG_compile_unit\fP.  This function is currently unimplemented.
  1057. .\"
  1058. .\".DS
  1059. .\"\f(CWDwarf_Die dwarf_pcsubr(
  1060. .\"        Dwarf_Debug dbg, 
  1061. .\"        Dwarf_Addr pc, 
  1062. .\"        Dwarf_Error *error)\fP
  1063. .\".DE
  1064. .\"The function
  1065. .\"\f(CWdwarf_pcsubr()\fP returns the \f(CWDwarf_Die\fP descriptor of the 
  1066. .\"subroutine debugging entry that contains the address of \f(CWpc\fP.  It 
  1067. .\"returns \fINULL\fP if no entry exists or an error occurred.  Currently 
  1068. .\"subroutine debugging information entries are defined as those having a 
  1069. .\"tag of: \f(CWDW_TAG_subprogram\fP, or \f(CWTAG_inlined_subroutine\fP.
  1070. .\"This function is currently unimplemented.
  1071. .\"
  1072. .\".DS
  1073. .\"\f(CWDwarf_Die dwarf_pcscope(
  1074. .\"        Dwarf_Debug dbg, 
  1075. .\"        Dwarf_Addr pc, 
  1076. .\"        Dwarf_Error *error)\fP
  1077. .\".DE
  1078. .\"The function
  1079. .\"\f(CWdwarf_pcscope()\fP returns the \f(CWDwarf_Die\fP descriptor for 
  1080. .\"the debugging information entry that represents the innermost enclosing 
  1081. .\"scope containing \f(CWpc\fP, or \fINULL\fP if no entry exists or an 
  1082. .\"error occurred. Debugging information entries that represent a \fIscope\fP 
  1083. .\"are those containing a low pc attribute and either a high pc or byte 
  1084. .\"size attribute that deliniates a range. For example: a debugging information 
  1085. .\"entry for a lexical block is considered one having a scope whereas a 
  1086. .\"debugging information entry for a label is not.  This function is
  1087. .\"currently unimplemented.
  1088. .\"#endif
  1089.  
  1090.  
  1091. .H 2 "Debugging Information Entry Query Operations"
  1092. These queries return specific information about debugging information 
  1093. entries or a descriptor that can be used on subsequent queries when 
  1094. given a \f(CWDwarf_Die\fP descriptor.  Note that some operations are 
  1095. specific to debugging information entries that are represented by a 
  1096. \f(CWDwarf_Die\fP descriptor of a specific type. 
  1097. For example, not all 
  1098. debugging information entries contain an attribute having a name, so 
  1099. consequently, a call to \f(CWdwarf_diename()\fP using a \f(CWDwarf_Die\fP 
  1100. descriptor that does not have a name attribute will return
  1101. \f(CWDW_DLV_NO_ENTRY\fP.
  1102. This is not an error, i.e. calling a function that needs a specific
  1103. attribute is not an error for a die that does not contain that specific
  1104. attribute.
  1105. .P
  1106. There are several methods that can be used to obtain the value of an
  1107. attribute in a given die:
  1108. .AL 1
  1109. .LI
  1110. Call \f(CWdwarf_hasattr()\fP to determine if the debugging information
  1111. entry has the attribute of interest prior to issuing the query for
  1112. information about the attribute.
  1113.  
  1114. .LI
  1115. Supply an \f(CWerror\fP argument, and check its value after the call to 
  1116. a query indicates an unsucessful return, to determine the nature of the 
  1117. problem.  The \f(CWerror\fP argument will indicate whether an error occurred, 
  1118. or the specific attribute needed was missing in that die.
  1119.  
  1120. .LI
  1121. Arrange to have an error handling function invoked upon detection of an 
  1122. error (see \f(CWdwarf_init()\fP).
  1123.  
  1124. .LI
  1125. Call \f(CWdwarf_attrlist()\fP and iterate through the returned list of
  1126. attributes, dealing with each one as appropriate.
  1127. .LE
  1128. .P
  1129.  
  1130. .DS
  1131. \f(CWint dwarf_tag(
  1132.         Dwarf_Die die, 
  1133.     Dwarf_Half *tagval,
  1134.         Dwarf_Error *error)\fP
  1135. .DE
  1136. The function \f(CWdwarf_tag()\fP returns the \fItag\fP of \f(CWdie\fP
  1137. thru the pointer  \f(CWtagval\fP if it succeeds. 
  1138. It returns \f(CWDW_DLV_OK\fP if it succeeds.
  1139. It returns \f(CWDW_DLV_ERROR\fP on error.
  1140.  
  1141. .DS
  1142. \f(CWint dwarf_dieoffset(
  1143.         Dwarf_Die die, 
  1144.     Dwarf_Off * return_offset,
  1145.         Dwarf_Error *error)\fP
  1146. .DE
  1147. When it succeeds,
  1148. the function \f(CWdwarf_dieoffset()\fP returns 
  1149. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP
  1150. to the position of \f(CWdie\fP 
  1151. in the section containing debugging information entries.  In other words,
  1152. it sets \f(CWreturn_offset\fP 
  1153. to the offset of the start of the debugging information entry
  1154. described by \f(CWdie\fP in the section containing die's i.e .debug_info.  
  1155. It returns \f(CWDW_DLV_ERROR\fP on error.
  1156.  
  1157. .DS
  1158. \f(CWint dwarf_die_CU_offset(
  1159.         Dwarf_Die die,
  1160.       Dwarf_Off *return_offset,
  1161.         Dwarf_Error *error)\fP
  1162. .DE
  1163. The function \f(CWdwarf_die_CU_offset()\fP is similar to 
  1164. \f(CWdwarf_dieoffset()\fP, except that it puts the offset of the DIE 
  1165. represented by the \f(CWDwarf_Die\fP \f(CWdie\fP, from the 
  1166. start of the compilation-unit that it belongs to rather than the start 
  1167. of .debug_info.  
  1168.  
  1169.  
  1170. .DS
  1171. \f(CWint dwarf_diename(
  1172.         Dwarf_Die die, 
  1173.     char  ** return_name,
  1174.         Dwarf_Error *error)\fP
  1175. .DE
  1176. When it succeeds,
  1177. the function \f(CWdwarf_diename()\fP returns
  1178. \f(CWDW_DLV_OK\fP and sets \f(CW*return_name\fP
  1179. to
  1180. a pointer to a
  1181. null-terminated string of characters that represents the name
  1182. attribute of \f(CWdie\fP.
  1183. It returns \f(CWDW_DLV_NO_ENTRY\fP if \f(CWdie\fP does not have a name attribute.
  1184. It returns \f(CWDW_DLV_ERROR\fP if
  1185. an error occurred.  
  1186. The storage pointed to by a successful return of 
  1187. \f(CWdwarf_diename()\fP should be free'd using the allocation type
  1188. \f(CWDW_DLA_STRING\fP when no longer of interest (see 
  1189. \f(CWdwarf_dealloc()\fP).
  1190.  
  1191. .DS
  1192. \f(CWint dwarf_attrlist(
  1193.         Dwarf_Die die, 
  1194.         Dwarf_Attribute** attrbuf, 
  1195.     Dwarf_Signed *attrcount,
  1196.         Dwarf_Error *error)\fP
  1197. .DE
  1198. When it returns \f(CWDW_DLV_OK\fP,
  1199. the function \f(CWdwarf_attrlist()\fP sets \f(CWattrbuf\fP to point 
  1200. to an array of \f(CWDwarf_Attribute\fP descriptors corresponding to
  1201. each of the attributes in die, and returns the number of elements in 
  1202. the array thru \f(CWattrcount\fP.  
  1203. \f(CWDW_DLV_NO_ENTRY\fP is returned if the count is zero (no 
  1204. \f(CWattrbuf\fP is allocated in this case).
  1205. \f(CWDW_DLV_ERROR\fP is returned on error.
  1206. On a successful return from \f(CWdwarf_attrlist()\fP, each of the
  1207. \f(CWDwarf_Attribute\fP descriptors should be individually free'd using 
  1208. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_ATTR\fP, 
  1209. followed by free-ing the list pointed to by \f(CW*attrbuf\fP using
  1210. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_LIST\fP, 
  1211. when no longer of interest (see \f(CWdwarf_dealloc()\fP).
  1212.  
  1213. Freeing the attrlist:
  1214. .in +2
  1215. .DS
  1216. \f(CWDwarf_Unsigned atcnt;
  1217. Dwarf_Attribute *atlist;
  1218. int errv;
  1219.  
  1220. if ((errv = dwarf_attrlist(somedie, &atlist,&atcnt, &error)) == DW_DLV_OK) {
  1221.  
  1222.         for (i = 0; i < atcnt; ++i) {
  1223.                 /* use atlist[i] */
  1224.                 dwarf_dealloc(dbg, atlist[i], DW_DLA_ATTR);
  1225.         }
  1226.         dwarf_dealloc(dbg, atlist, DW_DLA_LIST);
  1227. }\fP
  1228. .DE
  1229. .in -2
  1230. .P
  1231. .DS
  1232. \f(CWint dwarf_hasattr(
  1233.         Dwarf_Die die, 
  1234.         Dwarf_Half attr, 
  1235.     Dwarf_Bool *return_bool,
  1236.         Dwarf_Error *error)\fP
  1237. .DE
  1238. When it succeeds, the
  1239. function \f(CWdwarf_hasattr()\fP returns \f(CWDW_DLV_OK\fP
  1240. and sets \f(CW*return_bool\fP to \fInon-zero\fP if 
  1241. \f(CWdie\fP has the attribute \f(CWattr\fP and \fIzero\fP otherwise.
  1242. If it fails, it returns \f(CWDW_DLV_ERROR\fP.
  1243.  
  1244. .DS
  1245. \f(CWint dwarf_attr(
  1246.         Dwarf_Die die, 
  1247.         Dwarf_Half attr, 
  1248.     Dwarf_Attribute *return_attr,
  1249.         Dwarf_Error *error)\fP
  1250. .DE
  1251. When it returns \f(CWDW_DLV_OK\fP,
  1252. the function \f(CWdwarf_attr()\fP
  1253. sets 
  1254. \f(CW*return_attr\fP to the  \f(CWDwarf_Attribute\fP 
  1255. descriptor of \f(CWdie\fP having the attribute \f(CWattr\fP.
  1256. It returns \f(CDW_DLV_NO_ENTRY\fP if \f(CWattr\fP is not contained 
  1257. in \f(CWdie\fP. 
  1258. It returns \f(CDW_DLV_ERROR\fP if an error occurred.
  1259.  
  1260. .\"#if 0
  1261. .\".DS
  1262. .\"\f(CWDwarf_Locdesc* dwarf_stringlen(
  1263. .\"        Dwarf_Die die, 
  1264. .\"        Dwarf_Error *error)\fP
  1265. .\".DE
  1266. .\"The function \f(CWdwarf_stringlen()\fP returns a pointer to a 
  1267. .\"\f(CWDwarf_Locdesc\fP with one Locdesc entry that when evaluated,
  1268. .\"yields the length of the string represented by \f(CWdie\fP.  It
  1269. .\"returns \f(CWNULL\fP if \f(CWdie\fP does not contain a string length 
  1270. .\"attribute or the string length attribute is not a location-description 
  1271. .\"or an error occurred. The address range of the list is set to 0 thru 
  1272. .\"the highest possible address if a loclist pointer is returned.  The 
  1273. .\"storage pointed to by a successful return of \f(CWdwarf_stringlen()\fP 
  1274. .\"should be free'd when no longer of interest (see \f(CWdwarf_dealloc()\fP).
  1275. .\"This function is currently unimplemented.
  1276. .\"#endif
  1277.  
  1278. .\"#if 0
  1279. .\".DS
  1280. .\"\f(CWDwarf_Signed dwarf_subscrcnt(
  1281. .\"        Dwarf_Die die, 
  1282. .\"        Dwarf_Error *error)\fP
  1283. .\".DE
  1284. .\"The function \f(CWdwarf_subscrcnt()\fP returns the number of subscript 
  1285. .\"die's that are owned by the array type represented by \f(CWdie\fP.  It
  1286. .\"returns \f(CWDW_DLV_NOCOUNT\fP on error.  This function is currently
  1287. .\"unimplemented.
  1288. .\"
  1289. .\".DS
  1290. .\"\f(CWDwarf_Die dwarf_nthsubscr(
  1291. .\"        Dwarf_Die die, 
  1292. .\"        Dwarf_Unsigned ssndx, 
  1293. .\"        Dwarf_Error *error)\fP
  1294. .\".DE
  1295. .\"The function \f(CWdwarf_nthsubscr()\fP returns a \f(CWDwarf_Die\fP 
  1296. .\"descriptor that describes the \f(CWssndx\fP subscript of the array 
  1297. .\"type debugging information entry represented by \f(CWdie\fP, where 
  1298. .\"\fI1\fP is the first member.  It returns \fINULL\fP if \f(CWdie\fP 
  1299. .\"does not have an \f(CWssndx\fP subscript, or an error occurred.  
  1300. .\"This function is currently unimplemented.
  1301. .\"#endif
  1302.  
  1303. .DS
  1304. \f(CWint dwarf_lowpc(
  1305.         Dwarf_Die     die, 
  1306.     Dwarf_Addr  * return_lowpc,
  1307.         Dwarf_Error * error)\fP
  1308. .DE
  1309. The function \f(CWdwarf_lowpc()\fP returns
  1310. \f(CWDW_DLV_OK\fP and sets \f(CW*return_lowpc\fP
  1311. to the low program counter 
  1312. value associated with the \f(CWdie\fP descriptor if \f(CWdie\fP 
  1313. represents a debugging information entry with this attribute.  
  1314. It returns \f(CWDW_DLV_NO_ENTRY\fP if \f(CWdie\fP does not have this 
  1315. attribute. 
  1316. It returns \f(CWDW_DLV_ERROR\fP if an error occurred. 
  1317.  
  1318. .DS
  1319. \f(CWint dwarf_highpc(
  1320.         Dwarf_Die die, 
  1321.     Dwarf_Addr  * return_highpc,
  1322.         Dwarf_Error *error)\fP
  1323. .DE
  1324. The function \f(CWdwarf_highpc()\fP returns 
  1325. \f(CWDW_DLV_OK\fP and sets \f(CW*return_highpc\fP
  1326. the high program counter 
  1327. value associated with the \f(CWdie\fP descriptor if \f(CWdie\fP 
  1328. represents a debugging information entry with this attribute.  
  1329. It returns \f(CWDW_DLV_NO_ENTRY\fP if \f(CWdie\fP does not have this 
  1330. attribute. 
  1331. It returns \f(CWDW_DLV_ERROR\fP if an error occurred. 
  1332.  
  1333. .DS
  1334. \f(CWDwarf_Signed dwarf_bytesize(
  1335.         Dwarf_Die        die, 
  1336.     Dwarf_Unsigned  *return_size,
  1337.         Dwarf_Error     *error)\fP
  1338. .DE
  1339. When it succeeds,
  1340. \f(CWdwarf_bytesize()\fP returns 
  1341. \f(CWDW_DLV_OK\fP and sets \f(CW*return_size\fP
  1342. to the number of bytes 
  1343. needed to contain an instance of the aggregate debugging information 
  1344. entry represented by \f(CWdie\fP.  
  1345. It returns \f(CWDW_DLV_NO_ENTRY\fP if 
  1346. \f(CWdie\fP does not contain the byte size attribute \f(CWDW_AT_byte_size\fP.
  1347. It returns \f(CWDW_DLV_ERROR\fP if 
  1348. an error occurred.
  1349.  
  1350. .\"#if 0
  1351. .\".DS
  1352. .\"\f(CWDwarf_Bool dwarf_isbitfield(
  1353. .\"        Dwarf_Die die, 
  1354. .\"        Dwarf_Error *error)\fP
  1355. .\".DE
  1356. .\"The function \f(CWdwarf_isbitfield()\fP returns \fInon-zero\fP if 
  1357. .\"\f(CWdie\fP is a descriptor for a debugging information entry that 
  1358. .\"represents a bit field member.  It returns \fIzero\fP if \f(CWdie\fP 
  1359. .\"is not associated with a bit field member.  This function is currently
  1360. .\"unimplemented.
  1361. .\"#endif
  1362.  
  1363. .DS
  1364. \f(CWint dwarf_bitsize(
  1365.         Dwarf_Die die, 
  1366.     Dwarf_Unsigned  *return_size,
  1367.         Dwarf_Error *error)\fP
  1368. .DE
  1369. When it succeeds,
  1370. \f(CWdwarf_bitsize()\fP returns 
  1371. \f(CWDW_DLV_OK\fP and sets \f(CW*return_size\fP
  1372. to the number of 
  1373. bits 
  1374. occupied by the bit field value that is an attribute of the given
  1375. die.  
  1376. It returns \f(CWDW_DLV_NO_ENTRY\fP if \f(CWdie\fP does not 
  1377. contain the bit size attribute \f(CWDW_AT_bit_size\fP.
  1378. It returns \f(CWDW_DLV_ERROR\fP if 
  1379. an error occurred.
  1380.  
  1381. .DS
  1382. \f(CWint dwarf_bitoffset(
  1383.         Dwarf_Die die, 
  1384.     Dwarf_Unsigned  *return_size,
  1385.         Dwarf_Error *error)\fP
  1386. .DE
  1387. When it succeeds,
  1388. \f(CWdwarf_bitoffset()\fP returns 
  1389. \f(CWDW_DLV_OK\fP and sets \f(CW*return_size\fP
  1390. to the number of bits 
  1391. to the left of the most significant bit of the bit field value. 
  1392. It returns \f(CWDW_DLV_NO_ENTRY\fP if \f(CWdie\fP does not contain the 
  1393. bit offset attribute \f(CWDW_AT_bit_offset\fP.
  1394. It returns \f(CWDW_DLV_ERROR\fP if 
  1395. an error occurred.
  1396.  
  1397. .DS
  1398. \f(CWint dwarf_srclang(
  1399.         Dwarf_Die die, 
  1400.     Dwarf_Unsigned  *return_lang,
  1401.         Dwarf_Error *error)\fP
  1402. .DE
  1403. When it succeeds,
  1404. \f(CWdwarf_srclang()\fP returns
  1405. \f(CWDW_DLV_OK\fP and sets \f(CW*return_lang\fP
  1406. to
  1407. a code indicating the 
  1408. source language of the compilation unit represented by the descriptor 
  1409. \f(CWdie\fP.  
  1410. It returns \f(CWDW_DLV_NO_ENTRY\fP if \f(CWdie\fP does not 
  1411. represent a source file debugging information entry (i.e. contain the 
  1412. attribute \f(CWDW_AT_language\fP).
  1413. It returns \f(CWDW_DLV_ERROR\fP if 
  1414. an error occurred.
  1415.  
  1416. .DS
  1417. \f(CWint dwarf_arrayorder(
  1418.         Dwarf_Die die, 
  1419.     Dwarf_Unsigned  *return_order,
  1420.         Dwarf_Error *error)\fP
  1421. .DE
  1422. When it succeeds,
  1423. \f(CWdwarf_arrayorder()\fP returns
  1424. \f(CWDW_DLV_OK\fP and sets \f(CW*return_order\fP
  1425. a code indicating 
  1426. the ordering of the array represented by the descriptor \f(CWdie\fP.
  1427. It returns \f(CWDW_DLV_NO_ENTRY\fP if \f(CWdie\fP does not contain the
  1428. array order attribute \f(CWDW_AT_ordering\fP.
  1429. It returns \f(CWDW_DLV_ERROR\fP if 
  1430. an error occurred.
  1431.  
  1432. .H 2 "Attribute Form Queries"
  1433. Based on the attribute's form, these operations are concerned with 
  1434. returning uninterpreted attribute data.  Since it is not always 
  1435. obvious from the return value of these functions if an error occurred, 
  1436. one should always supply an \f(CWerror\fP parameter or have arranged 
  1437. to have an error handling function invoked (see \f(CWdwarf_init()\fP)
  1438. to determine the validity of the returned value and the nature of any 
  1439. errors that may have occurred.
  1440.  
  1441. A \f(CWDwarf_Attribute\fP descriptor describes an attribute of a
  1442. specific die.  Thus, each \f(CWDwarf_Attribute\fP descriptor is
  1443. implicitly associated with a specific die.
  1444.  
  1445. .DS
  1446. \f(CWnt dwarf_hasform(
  1447.         Dwarf_Attribute attr, 
  1448.         Dwarf_Half form, 
  1449.         Dwarf_Bool  *return_hasform,
  1450.         Dwarf_Error *error)\fP
  1451. .DE
  1452. The function \f(CWdwarf_hasform()\fP returns 
  1453. \f(CWDW_DLV_OK\fP and  and puts a 
  1454. \fInon-zero\fP
  1455.  value in the 
  1456. \f(CW*return_hasform\fP boolean if the 
  1457. attribute represented by the \f(CWDwarf_Attribute\fP descriptor 
  1458. \f(CWattr\fP has the attribute form \f(CWform\fP.  
  1459. If the attribute does not have that form \fIzero\fP
  1460. is put into \f(CW*return_hasform\fP. 
  1461. \f(CWDW_DLV_ERROR\fP is returned on error.
  1462.  
  1463. .DS
  1464. \f(CWint dwarf_whatform(
  1465.         Dwarf_Attribute attr,
  1466.         Dwarf_Half     *return_form,
  1467.         Dwarf_Error *error)\fP
  1468. .DE
  1469. When it succeeds,
  1470. \f(CWdwarf_whatform()\fP returns 
  1471. \f(CWDW_DLV_OK\fP and sets \f(CW*return_form\fP
  1472. to the attribute form code of 
  1473. the attribute represented by the \f(CWDwarf_Attribute\fP descriptor 
  1474. \f(CWattr\fP.  
  1475. It returns  \f(CWDW_DLV_ERROR\fP  on error.
  1476.  
  1477. .DS
  1478. \f(CWint dwarf_whatattr(
  1479.         Dwarf_Attribute attr,
  1480.         Dwarf_Half     *return_attr,
  1481.         Dwarf_Error *error)\fP
  1482. .DE
  1483. When it succeeds,
  1484. \f(CWdwarf_whatattr()\fP returns
  1485. \f(CWDW_DLV_OK\fP and sets \f(CW*return_attr\fP
  1486. to the attribute code 
  1487. represented by the \f(CWDwarf_Attribute\fP descriptor \f(CWattr\fP.  
  1488. It returns  \f(CWDW_DLV_ERROR\fP  on error.
  1489.  
  1490. .DS
  1491. \f(CWint dwarf_formref(
  1492.         Dwarf_Attribute attr, 
  1493.     Dwarf_Off     *return_offset,
  1494.         Dwarf_Error *error)\fP
  1495. .DE
  1496. When it succeeds,
  1497. \f(CWdwarf_formref()\fP returns 
  1498. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP
  1499. to the  offset
  1500. represented by the descriptor \f(CWattr\fP if the form of the attribute 
  1501. belongs to the \f(CWREFERENCE\fP class.  It is an error for the form to
  1502. not belong to this class.  It returns \f(CWDW_DLV_ERROR\fP on error.
  1503.  
  1504. .DS
  1505. \f(CWint dwarf_formaddr(
  1506.         Dwarf_Attribute attr, 
  1507.         Dwarf_Addr    * return_addr,
  1508.         Dwarf_Error *error)\fP
  1509. .DE
  1510. When it succeeds,
  1511. \f(CWdwarf_formaddr()\fP returns 
  1512. \f(CWDW_DLV_OK\fP and sets \f(CW*return_addr\fP
  1513. to
  1514. the address 
  1515. represented by the descriptor \f(CWattr\fP if the form of the attribute
  1516. belongs to the \f(CWADDRESS\fP class.  
  1517. It is an error for the form to
  1518. not belong to this class.  
  1519. It returns \f(CWDW_DLV_ERROR\fP on error.
  1520.  
  1521. .DS
  1522. \f(CWint dwarf_formflag(
  1523.     Dwarf_Attribute attr,
  1524.     Dwarf_Bool * return_bool,
  1525.     Dwarf_Error *error)\fP
  1526. .DE
  1527. When it succeeds,
  1528. \f(CWdwarf_formflag()\fP returns
  1529. \f(CWDW_DLV_OK\fP and sets \f(CW*return_bool\fP
  1530. \f(CW1\fP (i.e. true) (if the attribute has a non-zero value)
  1531. or \f(CW0\fP (i.e. false) (if the attribute has a zero value).
  1532. It returns \f(CWDW_DLV_ERROR\fP on error or if the \f(CWattr\fP
  1533. does not have form flag.
  1534.  
  1535. .DS
  1536. \f(CWint dwarf_formudata(
  1537.         Dwarf_Attribute   attr, 
  1538.     Dwarf_Unsigned  * return_uvalue,
  1539.         Dwarf_Error     * error)\fP
  1540. .DE
  1541. The function
  1542. \f(CWdwarf_formudata()\fP returns 
  1543. \f(CWDW_DLV_OK\fP and sets \f(CW*return_uvalue\fP
  1544. to
  1545. the \f(CWDwarf_Unsigned\fP 
  1546. value of the attribute represented by the descriptor \f(CWattr\fP if the
  1547. form of the attribute belongs to the \f(CWCONSTANT\fP class.  
  1548. It is an 
  1549. error for the form to not belong to this class.  
  1550. It returns \f(CWDW_DLV_ERROR\fP on error.
  1551.  
  1552. .DS
  1553. \f(CWint dwarf_formsdata(
  1554.         Dwarf_Attribute attr, 
  1555.     Dwarf_Signed  * return_svalue,
  1556.         Dwarf_Error *error)\fP
  1557. .DE
  1558. The function \f(CWdwarf_formsdata()\fP returns 
  1559. \f(CWDW_DLV_OK\fP and sets \f(CW*return_svalue\fP
  1560. to
  1561. the \f(CWDwarf_Signed\fP 
  1562. value of the attribute represented by the descriptor \f(CWattr\fP if the
  1563. form of the attribute belongs to the \f(CWCONSTANT\fP class.  
  1564. It is an 
  1565. error for the form to not belong to this class.  
  1566. If the size of the data 
  1567. attribute referenced is smaller than the size of the \f(CWDwarf_Signed\fP
  1568. type, its value is sign extended.  
  1569. It returns \f(CWDW_DLV_ERROR\fP on error.
  1570.  
  1571. .DS
  1572. \f(CWint dwarf_formblock(
  1573.         Dwarf_Attribute attr, 
  1574.     Dwarf_Block  ** return_block,
  1575.         Dwarf_Error *   error)\fP
  1576. .DE
  1577. The function \f(CWdwarf_formblock()\fP returns 
  1578. \f(CWDW_DLV_OK\fP and sets \f(CW*return_block\fP
  1579. to
  1580. a pointer to a 
  1581. \f(CWDwarf_Block\fP structure containing the value of the attribute 
  1582. represented by the descriptor \f(CWattr\fP if the form of the 
  1583. attribute belongs to the \f(CWBLOCK\fP class.  
  1584. It is an error
  1585. for the form to not belong to this class.  
  1586. The storage pointed 
  1587. to by a successful return of \f(CWdwarf_formblock()\fP should 
  1588. be free'd using the allocation type \f(CWDW_DLA_BLOCK\fP,  when 
  1589. no longer of interest (see \f(CWdwarf_dealloc()\fP).  
  1590. It returns
  1591. \f(CWDW_DLV_ERROR\fP on error.
  1592.  
  1593. .DS
  1594. \f(CWint dwarf_formstring(
  1595.         Dwarf_Attribute attr, 
  1596.     char        **  return_string,
  1597.         Dwarf_Error *error)\fP
  1598. .DE
  1599. The function \f(CWdwarf_formstring()\fP returns 
  1600. \f(CWDW_DLV_OK\fP and sets \f(CW*return_string\fP
  1601. to
  1602. a pointer to a 
  1603. null-terminated string containing  the value of the attribute 
  1604. represented by the descriptor \f(CWattr\fP if the form of the
  1605. attribute belongs to the \f(CWSTRING\fP class.  
  1606. It is an error
  1607. for the form to not belong to this class.  
  1608. The storage pointed 
  1609. to by a successful return of \f(CWdwarf_formstring()\fP should 
  1610. be free'd using the allocation type \f(CWDW_DLA_STRING\fP when 
  1611. no longer of interest (see \f(CWdwarf_dealloc()\fP).  
  1612. It returns \f(CWDW_DLV_ERROR\fP on error.
  1613.  
  1614. .DS
  1615. \f(CWint dwarf_loclist(
  1616.         Dwarf_Attribute attr, 
  1617.         Dwarf_Locdesc **llbuf,
  1618.         Dwarf_Signed  *listlen,
  1619.         Dwarf_Error *error)\fP
  1620. .DE
  1621. The function \f(CWdwarf_loclist()\fP sets \f(CW*llbuf\fP to point to 
  1622. an array of \f(CWDwarf_Locdesc\fP pointers corresponding to each of
  1623. the location expressions in a location list, and sets
  1624. \f(CW*listlen\fP to the number 
  1625. of elements in the array and returns \f(CWDW_DLV_OK\fP if the attribute is
  1626. appropriate.
  1627. It returns \f(CWDW_DLV_ERROR\fP on error. 
  1628. \f(CWdwarf_loclist()\fP works on \f(CWDW_AT_location\fP, 
  1629. \f(CWDW_AT_data_member_location\fP, \f(CWDW_AT_vtable_elem_location\fP,
  1630. \f(CWDW_AT_string_length\fP, \f(CWDW_AT_use_location\fP, and 
  1631. \f(CWDW_AT_return_addr\fP attributes.  
  1632.  
  1633. Storage allocated by a successful call of \f(CWdwarf_loclist()\fP should 
  1634. be deallocated when no longer of interest (see \f(CWdwarf_dealloc()\fP).
  1635. The block of \f(CWDwarf_Loc\fP structs pointed to by the \f(CWld_s\fP 
  1636. field of each \f(CWDwarf_Locdesc\fP structure 
  1637. should be deallocated with the allocation type \f(CWDW_DLA_LOC_BLOCK\fP. 
  1638. This should be followed by deallocation of the \f(CWllbuf\fP
  1639. using the allocation type \f(CWDW_DLA_LOCDESC\fP.
  1640. .in +2
  1641. .DS
  1642. \f(CWDwarf_Signed lcnt;
  1643. Dwarf_Locdesc *llbuf;
  1644. int lres;
  1645.  
  1646. if ((lres = dwarf_loclist(someattr, &llbuf,&lcnt &error)) == DW_DLV_OK) {
  1647.         for (i = 0; i < lcnt; ++i) {
  1648.             /* use llbuf[i] */
  1649.  
  1650.             /* Deallocate Dwarf_Loc block of llbuf[i] */
  1651.             dwarf_dealloc(dbg, llbuf[i].ld_s, DW_DLA_LOC_BLOCK);
  1652.  
  1653.         }
  1654.         dwarf_dealloc(dbg, llbuf, DW_DLA_LOCDESC);
  1655. }\fP
  1656. .DE
  1657. .in -2
  1658. .P
  1659.  
  1660. .P
  1661. .H 2 "Line Number Operations"
  1662. These functions are concerned with accessing line number entries,
  1663. mapping debugging information entry objects to their corresponding
  1664. source lines, and providing a mechanism for obtaining information
  1665. about line number entries.  Although, the interface talks of "lines"
  1666. what is really meant is "statements".  In case there is more than
  1667. one statement on the same line, there will be at least one descriptor
  1668. per statement, all with the same line number.  If column number is
  1669. also being represented they will have the column numbers of the start
  1670. of the statements also represented.
  1671. .P
  1672. There can also be more than one Dwarf_Line per statement.
  1673. For example, if a file is preprocessed by a language translator,
  1674. this could result in translator output showing 2 or more sets of line
  1675. numbers per translated line of output.
  1676.  
  1677. .H 3 "Get A Set of Lines"
  1678. The function returns information about every source line for a 
  1679. particular compilation-unit.  The compilation-unit is specified
  1680. by the corresponding die.
  1681.  
  1682. .DS
  1683. \f(CWint dwarf_srclines(
  1684.         Dwarf_Die die, 
  1685.         Dwarf_Line **linebuf, 
  1686.     Dwarf_Signed *linecount,
  1687.         Dwarf_Error *error)\fP
  1688. .DE
  1689. The function \f(CWdwarf_srclines()\fP places all line number descriptors 
  1690. for a single compilation unit into a single block, sets \f(CW*linebuf\fP 
  1691. to point to that block, 
  1692. sets \f(CW*linecount\fP to the number of descriptors in this block
  1693. and returns \f(CWDW_DLV_OK\fP.
  1694. The compilation-unit is indicated by the given \f(CWdie\fP which must be
  1695. a compilation-unit die.  
  1696. It returns \f(CWDW_DLV_ERROR\fP on error.  
  1697. On
  1698. successful return, each line number information structure pointed to by 
  1699. an entry in the block should be free'd using \f(CWdwarf_dealloc()\fP with 
  1700. the allocation type \f(CWDW_DLA_LINE\fP when no longer of interest.  Also 
  1701. the block of descriptors itself should be free'd using \f(CWdwarf_dealloc()\fP
  1702. with the allocation type \f(CWDW_DLA_LIST\fP when no longer of interest.
  1703. .P
  1704. .in +2
  1705. .DS
  1706. \f(CWDwarf_Signed cnt;
  1707. Dwarf_Line *linebuf;
  1708. int sres;
  1709.  
  1710. if ((sres = dwarf_srclines(somedie, &linebuf, &error)) == DW_DLV_OK) {
  1711.  
  1712.         for (i = 0; i < cnt; ++i) {
  1713.                 /* use linebuf[i] */
  1714.                 dwarf_dealloc(dbg, linebuf[i], DW_DLA_LINE);
  1715.         }
  1716.         dwarf_dealloc(dbg, linebuf, DW_DLA_LIST);
  1717. }\fP
  1718. .DE
  1719. .in -2
  1720.  
  1721. .H 3 "Get the set of Source File Names"
  1722.  
  1723. The function returns the names of the source files that have contributed
  1724. to the compilation-unit represented by the given DIE.  Only the source
  1725. files named in the statement program prologue are returned.
  1726.  
  1727. .DS
  1728. \f(CWint dwarf_srcfiles(
  1729.         Dwarf_Die die,
  1730.         char ***srcfiles,
  1731.         Dwarf_Signed *srccount,
  1732.         Dwarf_Error *error)\fP
  1733. .DE
  1734. When it succeeds
  1735. \f(CWdwarf_srcfiles()\fP returns 
  1736. \f(CWDW_DLV_OK\fP
  1737. and
  1738. puts
  1739. the number of source
  1740. files named in the statement program prologue indicated by the given
  1741. \f(CWdie\fP
  1742. into \f(CW*srccount\fP.  
  1743. Source files defined in the statement program are ignored.
  1744. The given \f(CWdie\fP should have the tag \f(CWDW_TAG_compile_unit\fP.
  1745. The location pointed to by \f(CWsrcfiles\fP is set to point to a list
  1746. of pointers to null-terminated strings that name the source
  1747. files.  
  1748. On a successful return from this function, each of the
  1749. strings returned should be individually free'd using \f(CWdwarf_dealloc()\fP
  1750. with the allocation type \f(CWDW_DLA_STRING\fP when no longer of
  1751. interest.  
  1752. This should be followed by free-ing the list using
  1753. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_LIST\fP.
  1754. It returns \f(CWDW_DLV_ERROR\fP on error. 
  1755. It returns \f(CWDW_DLV_NO_ENTRY\fP
  1756. if there is no
  1757. corresponding statement program (i.e., if there is no line information).
  1758. .in +2
  1759. .DS
  1760. \f(CWDwarf_Signed cnt;
  1761. char **srcfiles;
  1762. int res;
  1763.  
  1764. if ((res = dwarf_srcfiles(somedie, &srcfiles,&cnt &error)) == DW_DLV_OK) {
  1765.  
  1766.         for (i = 0; i < cnt; ++i) {
  1767.                 /* use srcfiles[i] */
  1768.                 dwarf_dealloc(dbg, srcfiles[i], DW_DLA_STRING);
  1769.         }
  1770.         dwarf_dealloc(dbg, srcfiles, DW_DLA_LIST);
  1771. }\fP
  1772. .DE
  1773. .in -2
  1774. .H 3 "Get information about a Single Table Line"
  1775. The following functions can be used on the \f(CWDwarf_Line\fP descriptors
  1776. returned by \f(CWdwarf_srclines()\fP to obtain information about the
  1777. source lines.
  1778.  
  1779. .DS
  1780. \f(CWint dwarf_linebeginstatement(
  1781.         Dwarf_Line line, 
  1782.     Dwarf_Bool *return_bool,
  1783.         Dwarf_Error *error)\fP
  1784. .DE
  1785. The function \f(CWdwarf_linebeginstatement()\fP returns 
  1786. \f(CWDW_DLV_OK\fP and sets \f(CW*return_bool\fP
  1787. to
  1788. \fInon-zero\fP 
  1789. (if \f(CWline\fP represents a line number entry that is marked as
  1790. beginning a statement).  
  1791. or
  1792. \fIzero\fP ((if \f(CWline\fP represents a line number entry
  1793. that is not marked as beginning a statement).
  1794. It returns \f(CWDW_DLV_ERROR\fP on error.
  1795. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1796.  
  1797. .P
  1798. .DS
  1799. \f(CWint dwarf_lineendsequence(
  1800.     Dwarf_Line line,
  1801.     Dwarf_Bool *return_bool,
  1802.     Dwarf_Error *error)\fP
  1803. .DE
  1804. The function \f(CWdwarf_lineendsequence()\fP returns
  1805. \f(CWDW_DLV_OK\fP and sets \f(CW*return_bool\fP
  1806. \fInon-zero\fP
  1807. if \f(CWline\fP represents a line number entry that is marked as
  1808. ending a text sequence)
  1809. or
  1810. \fIzero\fP ((if \f(CWline\fP represents a line number entry
  1811. that is not marked as ending a text sequence).
  1812. It returns \f(CWDW_DLV_ERROR\fP on error.
  1813. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1814.  
  1815. .P
  1816. .DS
  1817. \f(CWint dwarf_lineno(
  1818.         Dwarf_Line       line, 
  1819.     Dwarf_Unsigned * returned_lineno,
  1820.         Dwarf_Error    * error)\fP
  1821. .DE
  1822. The function \f(CWdwarf_lineno()\fP returns 
  1823. \f(CWDW_DLV_OK\fP and sets \f(CW*return_lineno\fP to
  1824. the source statement line 
  1825. number corresponding to the descriptor \f(CWline\fP.  
  1826. It returns \f(CWDW_DLV_ERROR\fP on error.
  1827. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1828.  
  1829. .P
  1830. .DS
  1831. \f(CWint dwarf_lineaddr(
  1832.         Dwarf_Line   line, 
  1833.     Dwarf_Addr  *return_lineaddr,
  1834.         Dwarf_Error *error)\fP
  1835. .DE
  1836. The function \f(CWdwarf_lineaddr()\fP returns 
  1837. \f(CWDW_DLV_OK\fP and sets \f(CW*return_lineaddr\fP to
  1838. the address associated 
  1839. with the descriptor \f(CWline\fP.  
  1840. It returns \f(CWDW_DLV_ERROR\fP  on error.
  1841. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1842.  
  1843. .P
  1844. .DS
  1845. \f(CWint dwarf_lineoff(
  1846.         Dwarf_Line line, 
  1847.     Dwarf_Signed   * return_lineoff,
  1848.         Dwarf_Error *error)\fP
  1849. .DE
  1850. The function \f(CWdwarf_lineoff()\fP returns 
  1851. \f(CWDW_DLV_OK\fP and sets \f(CW*return_lineoff\fP to
  1852. the column number at which
  1853. the statement represented by \f(CWline\fP begins.  
  1854. It sets \f(CWreturn_lineoff\fP to \fI-1\fP 
  1855. if the column number of the statement is not represented.  
  1856. On error it returns \f(CWDW_DLV_ERROR\fP.
  1857. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1858.  
  1859. .DS
  1860. \f(CWint dwarf_linesrc(
  1861.         Dwarf_Line line, 
  1862.     char  **   return_linesrc,
  1863.         Dwarf_Error *error)\fP
  1864. .DE
  1865. The function \f(CWdwarf_linesrc()\fP returns
  1866. \f(CWDW_DLV_OK\fP and sets \f(CW*return_linesrc\fP to
  1867. a pointer to a
  1868. null-terminated string of characters that represents the name of the 
  1869. source-file where \f(CWline\fP occurs.  
  1870. It returns \f(CWDW_DLV_ERROR\fP on 
  1871. error.  
  1872. The storage pointed to by a successful return of 
  1873. \f(CWdwarf_linesrc()\fP should be free'd using \f(CWdwarf_dealloc()\fP with
  1874. the allocation type \f(CWDW_DLA_STRING\fP when no longer of interest.
  1875. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1876.  
  1877. .DS
  1878. \f(CWint dwarf_lineblock(
  1879.         Dwarf_Line line, 
  1880.     Dwarf_Bool *return_bool,
  1881.         Dwarf_Error *error)\fP
  1882. .DE
  1883. The function
  1884. \f(CWdwarf_lineblock()\fP returns 
  1885. \f(CWDW_DLV_OK\fP and sets \f(CW*return_linesrc\fP to
  1886. non-zero (i.e. true)(if the line is marked as 
  1887. beginning a basic block)
  1888. or zero (i.e. false) (if the line is marked as not
  1889. beginning a basic block).  
  1890. It returns \f(CWDW_DLV_ERROR\fP on error.
  1891. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1892.  
  1893. .\"#if 0
  1894. .\".H 3 "Finding a Line Given A PC value"
  1895. .\"This is a 'higher level' (High-level) interface to line information.
  1896. .\"
  1897. .\".DS
  1898. .\"\f(CWint dwarf_pclines(
  1899. .\"        Dwarf_Debug dbg,
  1900. .\"        Dwarf_Addr pc,
  1901. .\"        Dwarf_Line **linebuf,
  1902. .\"        Dwarf_Signed slide,
  1903. .\"        Dwarf_Signed *linecount,
  1904. .\"        Dwarf_Error *error)\fP
  1905. .\".DE
  1906. .\"The function \f(CWdwarf_pclines()\fP places all line number descriptors 
  1907. .\"that correspond to the value of \f(CWpc\fP into a single block and sets 
  1908. .\"\f(CWlinebuf\fP to point to that block.  A count of the number of 
  1909. .\"\f(CWDwarf_Line\fP descriptors that are in this block is returned.  For 
  1910. .\"most cases, the count returned will be \fIone\fP, though it may be higher 
  1911. .\"if optimizations such as common subexpression elimination result in multiple 
  1912. .\"line number entries for a given value of \f(CWpc\fP.  The \f(CWslide\fP 
  1913. .\"argument specifies the direction to search for the nearest line number 
  1914. .\"entry in the event that there is no line number entry that contains an 
  1915. .\"exact match for \f(CWpc\fP.  This argument may be one of: 
  1916. .\"\f(CWDLS_BACKWARD\fP, \f(CWDLS_NOSLIDE\fP, \f(CWDLS_FORWARD\fP.
  1917. .\"\f(CWDW_DLV_NOCOUNT\fP is returned on error.  On successful return, each 
  1918. .\"line information structure pointed to by an entry in the block should be 
  1919. .\"free'd using \f(CWdwarf_dealloc()\fP with the allocation type 
  1920. .\"\f(CWDW_DLA_LINE\fP when no longer of interest.  The block itself should 
  1921. .\"be free'd using \f(CWdwarf_dealloc()\fP with the allocation type 
  1922. .\"\f(CWDW_DLA_LIST\fP when no longer of interest.
  1923. .\"#endif
  1924.  
  1925. .H 2 "Global Name Space Operations" 
  1926. These operations operate on the .debug_pubnames section of the debugging 
  1927. information.
  1928.  
  1929. .H 3 "Debugger Interface Operations"
  1930.  
  1931. .DS
  1932. \f(CWint dwarf_get_globals(
  1933.         Dwarf_Debug dbg,
  1934.         Dwarf_Global **globals,
  1935.         Dwarf_Signed * return_count,
  1936.         Dwarf_Error *error)\fP
  1937. .DE
  1938. The function \f(CWdwarf_get_globals()\fP returns 
  1939. \f(CWDW_DLV_OK\fP and sets \f(CW*return_count\fP to
  1940. the count of pubnames
  1941. represented in the section containing pubnames i.e. .debug_pubnames.  
  1942. It also stores at \f(CW*globals\fP, a pointer 
  1943. to a list of \f(CWDwarf_Global\fP descriptors, one for each of the 
  1944. pubnames in the .debug_pubnames section.  
  1945. It returns \f(CWDW_DLV_ERROR\fP on error. 
  1946. It returns \f(CWDW_DLV_NO_ENTRY\fP if the .debug_pubnames 
  1947. section does not exist.
  1948.  
  1949. On a successful return from 
  1950. this function, the \f(CWDwarf_Global\fP descriptors should be individually 
  1951. free'd using \f(CWdwarf_dealloc()\fP with the allocation type 
  1952. \f(CWDW_DLA_GLOBAL\fP, followed by the deallocation of the list itself 
  1953. with the allocation type \f(CWDW_DLA_LIST\fP when the descriptors are 
  1954. no longer of interest.
  1955.  
  1956. .in +2
  1957. .DS
  1958. \f(CWDwarf_Signed cnt;
  1959. Dwarf_Global *globs;
  1960. int res;
  1961.  
  1962. if ((res = dwarf_get_globals(dbg, &globs,&cnt, &error)) == DW_DLV_OK) {
  1963.  
  1964.         for (i = 0; i < cnt; ++i) {
  1965.                 /* use globs[i] */
  1966.                 dwarf_dealloc(dbg, globs[i], DW_DLA_GLOBAL);
  1967.         }
  1968.         dwarf_dealloc(dbg, globs, DW_DLA_LIST);
  1969. }\fP
  1970. .DE
  1971. .in -2
  1972.  
  1973. .DS
  1974. \f(CWint dwarf_globname(
  1975.         Dwarf_Global global,
  1976.         char **      return_name,
  1977.         Dwarf_Error *error)\fP
  1978. .DE
  1979. The function \f(CWdwarf_globname()\fP returns
  1980. \f(CWDW_DLV_OK\fP and sets \f(CW*return_name\fP to
  1981. a pointer to a 
  1982. null-terminated string that names the pubname represented by the 
  1983. \f(CWDwarf_Global\fP descriptor, \f(CWglobal\fP.  
  1984. It returns \f(CWDW_DLV_ERROR\fP on error.  
  1985. On a successful return from this function, the string should
  1986. be free'd using \f(CWdwarf_dealloc()\fP, with the allocation type
  1987. \f(CWDW_DLA_STRING\fP when no longer of interest.
  1988. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  1989.  
  1990. .DS
  1991. \f(CWint dwarf_global_die_offset(
  1992.         Dwarf_Global global,
  1993.     Dwarf_Off   *return_offset,
  1994.         Dwarf_Error *error)\fP
  1995. .DE
  1996. The function \f(CWdwarf_global_die_offset()\fP returns
  1997. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to
  1998. the offset in
  1999. the section containing DIE's, i.e. .debug_info, of the DIE representing
  2000. the pubname that is described by the \f(CWDwarf_Global\fP descriptor, 
  2001. \f(CWglob\fP.  
  2002. It returns \f(CWDW_DLV_ERROR\fP on error.
  2003. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2004.  
  2005. .DS
  2006. \f(CWint dwarf_global_cu_offset(
  2007.         Dwarf_Global global,
  2008.     Dwarf_Off   *return_offset,
  2009.         Dwarf_Error *error)\fP
  2010. .DE
  2011. The function \f(CWdwarf_global_cu_offset()\fP returns 
  2012. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to
  2013. the offset in
  2014. the section containing DIE's, i.e. .debug_info, of the compilation-unit
  2015. header of the compilation-unit that contains the pubname described 
  2016. by the \f(CWDwarf_Global\fP descriptor, \f(CWglobal\fP.  
  2017. It returns \f(CWDW_DLV_ERROR\fP on error.
  2018. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2019.  
  2020. .DS
  2021. \f(CWint dwarf_global_name_offsets(
  2022.         Dwarf_Global global,
  2023.         char     **return_name,
  2024.         Dwarf_Off *die_offset,
  2025.         Dwarf_Off *cu_offset,
  2026.         Dwarf_Error *error)\fP
  2027. .DE
  2028. The function \f(CWdwarf_global_name_offsets()\fP returns
  2029. \f(CWDW_DLV_OK\fP and sets \f(CW*return_name\fP to
  2030. a pointer to
  2031. a null-terminated string that gives the name of the pubname
  2032. described by the \f(CWDwarf_Global\fP descriptor \f(CWglobal\fP.  
  2033. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2034. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2035. It also returns in the locations 
  2036. pointed to by \f(CWdie_offset\fP, and \f(CWcu_offset\fP, the offsets
  2037. of the DIE representing the pubname, and the compilation-unit header 
  2038. of the compilation-unit containing the pubname, respectively.  
  2039. On a 
  2040. successful return from \f(CWdwarf_global_name_offsets()\fP the storage 
  2041. pointed to by \f(CWreturn_name\fP 
  2042. should be free'd using \f(CWdwarf_dealloc()\fP, 
  2043. with the allocation type \f(CWDW_DLA_STRING\fP when no longer of interest.
  2044.  
  2045. .H 2 "Weak Name Space Operations" 
  2046. These operations operate on the .debug_weaknames section of the debugging 
  2047. information.
  2048. .P
  2049. These operations are SGI specific, not part of standard DWARF.
  2050. .P
  2051.  
  2052. .H 3 "Debugger Interface Operations"
  2053.  
  2054. .DS
  2055. \f(CWint dwarf_get_weaks(
  2056.         Dwarf_Debug dbg,
  2057.         Dwarf_Weak **weaks,
  2058.     Dwarf_Signed *weak_count,
  2059.         Dwarf_Error *error)\fP
  2060. .DE
  2061. The function \f(CWdwarf_get_weaks()\fP returns
  2062. \f(CWDW_DLV_OK\fP and sets \f(CW*weak_count\fP to
  2063. the count of weak names
  2064. represented in the section containing weak names i.e. .debug_weaknames.  
  2065. It returns \f(CWDW_DLV_ERROR\fP on error. 
  2066. It returns \f(CWDW_DLV_NO_ENTRY\fP if the section does not exist.  
  2067. It also stores in \f(CW*weaks\fP, a pointer to 
  2068. a list of \f(CWDwarf_Weak\fP descriptors, one for each of the weak names 
  2069. in the .debug_weaknames section.  
  2070. On a successful return from this function, 
  2071. the \f(CWDwarf_Weak\fP descriptors should be individually free'd using 
  2072. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_WEAK\fP, 
  2073. followed by the deallocation of the list itself with the allocation type 
  2074. \f(CWDW_DLA_LIST\fP when the descriptors are no longer of interest.
  2075.  
  2076. .in +2
  2077. .DS
  2078. \f(CWDwarf_Signed cnt;
  2079. Dwarf_Weak *weaks;
  2080. int res;
  2081.  
  2082. if ((res = dwarf_get_weaks(dbg, &weaks,&cnt, &error)) == DW_DLV_OK) {
  2083.  
  2084.         for (i = 0; i < cnt; ++i) {
  2085.                 /* use weaks[i] */
  2086.                 dwarf_dealloc(dbg, weaks[i], DW_DLA_WEAK);
  2087.         }
  2088.         dwarf_dealloc(dbg, weaks, DW_DLA_LIST);
  2089. }\fP
  2090. .DE
  2091. .in -2
  2092.  
  2093. .DS
  2094. \f(CWint dwarf_weakname(
  2095.         Dwarf_Weak weak,
  2096.     char    ** return_name,
  2097.         Dwarf_Error *error)\fP
  2098. .DE
  2099. The function \f(CWdwarf_weakname()\fP returns
  2100. \f(CWDW_DLV_OK\fP and sets \f(CW*return_name\fP to
  2101. a pointer to a null-terminated
  2102. string that names the weak name represented by the 
  2103. \f(CWDwarf_Weak\fP descriptor, \f(CWweak\fP.  
  2104. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2105. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2106. On a successful return from this function, the string should
  2107. be free'd using \f(CWdwarf_dealloc()\fP, with the allocation type
  2108. \f(CWDW_DLA_STRING\fP when no longer of interest.
  2109.  
  2110. .DS
  2111. \f(CWint dwarf_weak_die_offset(
  2112.         Dwarf_Weak weak,
  2113.     Dwarf_Off  *return_offset,
  2114.         Dwarf_Error *error)\fP
  2115. .DE
  2116. The function \f(CWdwarf_weak_die_offset()\fP returns
  2117. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to the offset in
  2118. the section containing DIE's, i.e. .debug_info, of the DIE representing
  2119. the weak name that is described by the \f(CWDwarf_Weak\fP descriptor, 
  2120. \f(CWweak\fP.  
  2121. It returns \f(CWDW_DLV_ERROR\fP on error.
  2122. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2123.  
  2124. .DS
  2125. \f(CWint dwarf_weak_cu_offset(
  2126.         Dwarf_Weak weak,
  2127.     Dwarf_Off  *return_offset,
  2128.         Dwarf_Error *error)\fP
  2129. .DE
  2130. The function \f(CWdwarf_weak_cu_offset()\fP returns
  2131. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to the offset in
  2132. the section containing DIE's, i.e. .debug_info, of the compilation-unit
  2133. header of the compilation-unit that contains the weak name described 
  2134. by the \f(CWDwarf_Weak\fP descriptor, \f(CWweak\fP.  
  2135. It returns \f(CWDW_DLV_ERROR\fP on error.
  2136. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2137.  
  2138. .DS
  2139. \f(CWint dwarf_weak_name_offsets(
  2140.         Dwarf_Weak weak,
  2141.     char **  weak_name,
  2142.         Dwarf_Off *die_offset,
  2143.         Dwarf_Off *cu_offset,
  2144.         Dwarf_Error *error)\fP
  2145. .DE
  2146. The function \f(CWdwarf_weak_name_offsets()\fP returns
  2147. \f(CWDW_DLV_OK\fP and sets \f(CW*weak_name\fP to
  2148. a pointer to
  2149. a null-terminated string that gives the name of the weak name
  2150. described by the \f(CWDwarf_Weak\fP descriptor \f(CWweak\fP.  
  2151. It also returns in the locations 
  2152. pointed to by \f(CWdie_offset\fP, and \f(CWcu_offset\fP, the offsets
  2153. of the DIE representing the weak name, and the compilation-unit header 
  2154. of the compilation-unit containing the weak name, respectively.  
  2155. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2156. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2157. On a 
  2158. successful return from \f(CWdwarf_weak_name_offsets()\fP the storage 
  2159. pointed to by the return value should be free'd using \f(CWdwarf_dealloc()\fP, 
  2160. with the allocation type \f(CWDW_DLA_STRING\fP when no longer of interest.
  2161.  
  2162. .H 2 "Static Function Names Operations"
  2163. This section is SGI specific and is not part of standard DWARF version 2.
  2164. .P
  2165. These function operate on the .debug_funcnames section of the debugging
  2166. information.  The .debug_funcnames section contains the names of static
  2167. functions defined in the object, the offsets of the \f(CWDIE\fPs that
  2168. represent the definitions of the corresponding functions, and the offsets
  2169. of the start of the compilation-units that contain the definitions of
  2170. those functions.
  2171.  
  2172. .H 3 "Debugger Interface Operations"
  2173.  
  2174. .DS
  2175. \f(CWint dwarf_get_funcs(
  2176.         Dwarf_Debug dbg,
  2177.         Dwarf_Func **funcs,
  2178.         Dwarf_Signed *func_count,
  2179.         Dwarf_Error *error)\fP
  2180. .DE
  2181. The function \f(CWdwarf_get_funcs()\fP returns
  2182. \f(CWDW_DLV_OK\fP and sets \f(CW*func_count\fP to
  2183. the count of static
  2184. function names represented in the section containing static function
  2185. names, i.e. .debug_funcnames.  
  2186. It also 
  2187. stores, at \f(CW*funcs\fP, a pointer to a list of \f(CWDwarf_Func\fP 
  2188. descriptors, one for each of the static functions in the .debug_funcnames 
  2189. section.  
  2190. It returns \f(CWDW_DLV_NOCOUNT\fP on error.
  2191. It returns \f(CWDW_DLV_NO_ENTRY\fP
  2192. if the .debug_funcnames section does not exist.  
  2193. On a successful return from this function, the \f(CWDwarf_Func\fP 
  2194. descriptors should be individually free'd using \f(CWdwarf_dealloc()\fP 
  2195. with the allocation type \f(CWDW_DLA_FUNC\fP, followed by the deallocation 
  2196. of the list itself with the allocation type \f(CWDW_DLA_LIST\fP when 
  2197. the descriptors are no longer of interest.
  2198.  
  2199. .in +2
  2200. .DS
  2201. \f(CWDwarf_Signed cnt;
  2202. Dwarf_Func *funcs;
  2203. int fres;
  2204.  
  2205. if ((fres = dwarf_get_funcs(dbg, &funcs, &error)) == DW_DLV_OK) {
  2206.  
  2207.         for (i = 0; i < cnt; ++i) {
  2208.                 /* use funcs[i] */
  2209.                 dwarf_dealloc(dbg, funcs[i], DW_DLA_FUNC);
  2210.         }
  2211.         dwarf_dealloc(dbg, funcs, DW_DLA_LIST);
  2212. }\fP
  2213. .DE
  2214. .in -2
  2215.  
  2216. .DS
  2217. \f(CWint dwarf_funcname(
  2218.         Dwarf_Func func,
  2219.         char **    return_name,
  2220.         Dwarf_Error *error)\fP
  2221. .DE
  2222. The function \f(CWdwarf_funcname()\fP returns
  2223. \f(CWDW_DLV_OK\fP and sets \f(CW*return_name\fP to
  2224. a pointer to a
  2225. null-terminated string that names the static function represented by the
  2226. \f(CWDwarf_Func\fP descriptor, \f(CWfunc\fP.  
  2227. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2228. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2229. On a successful return from this function, the string should
  2230. be free'd using \f(CWdwarf_dealloc()\fP, with the allocation type
  2231. \f(CWDW_DLA_STRING\fP when no longer of interest.
  2232.  
  2233. .DS
  2234. \f(CWint dwarf_func_die_offset(
  2235.         Dwarf_Func func,
  2236.     Dwarf_Off  *return_offset,
  2237.         Dwarf_Error *error)\fP
  2238. .DE
  2239. The function \f(CWdwarf_func_die_offset()\fP, returns
  2240. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to
  2241. the offset in
  2242. the section containing DIE's, i.e. .debug_info, of the DIE representing
  2243. the static function that is described by the \f(CWDwarf_Func\fP 
  2244. descriptor, \f(CWfunc\fP.  
  2245. It returns \f(CWDW_DLV_ERROR\fP on error.
  2246. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2247.  
  2248. .DS
  2249. \f(CWint dwarf_func_cu_offset(
  2250.         Dwarf_Func func,
  2251.     Dwarf_Off  *return_offset,
  2252.         Dwarf_Error *error)\fP
  2253. .DE
  2254. The function \f(CWdwarf_func_cu_offset()\fP returns
  2255. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to
  2256. the offset in
  2257. the section containing DIE's, i.e. .debug_info, of the compilation-unit
  2258. header of the compilation-unit that contains the static function
  2259. described by the \f(CWDwarf_Func\fP descriptor, \f(CWfunc\fP.  
  2260. It returns \f(CWDW_DLV_ERROR\fP on error.
  2261. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2262.  
  2263. .DS
  2264. \f(CWint dwarf_func_name_offsets(
  2265.         Dwarf_Func func,
  2266.     char     **func_name,
  2267.         Dwarf_Off *die_offset,
  2268.         Dwarf_Off *cu_offset,
  2269.         Dwarf_Error *error)\fP
  2270. .DE
  2271. The function \f(CWdwarf_func_name_offsets()\fP returns
  2272. \f(CWDW_DLV_OK\fP and sets \f(CW*func_name\fP to
  2273. a pointer to
  2274. a null-terminated string that gives the name of the static
  2275. function described by the \f(CWDwarf_Func\fP descriptor \f(CWfunc\fP.
  2276. It also returns in the locations
  2277. pointed to by \f(CWdie_offset\fP, and \f(CWcu_offset\fP, the offsets
  2278. of the DIE representing the static function, and the compilation-unit 
  2279. header of the compilation-unit containing the static function,
  2280. respectively.  
  2281. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2282. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2283. On a successful return from \f(CWdwarf_func_name_offsets()\fP
  2284. the storage pointed to by the return value should be free'd using
  2285. \f(CWdwarf_dealloc()\fP, with the allocation type \f(CWDW_DLA_STRING\fP
  2286. when no longer of interest.
  2287.  
  2288. .H 2 "User Defined Type Names Operations"
  2289. This section is SGI specific and is not part of standard DWARF version 2.
  2290. .P
  2291. These functions operate on the .debug_typenames section of the debugging
  2292. information.  The .debug_typenames section contains the names of file-scope
  2293. user-defined types, the offsets of the \f(CWDIE\fPs that represent the
  2294. definitions of those types, and the offsets of the compilation-units 
  2295. that contain the definitions of those types.
  2296.  
  2297. .H 3 "Debugger Interface Operations"
  2298.  
  2299. .DS
  2300. \f(CWint dwarf_get_types(
  2301.         Dwarf_Debug dbg,
  2302.         Dwarf_Type **types,
  2303.         Dwarf_Signed *typecount,
  2304.         Dwarf_Error *error)\fP
  2305. .DE
  2306. The function \f(CWdwarf_get_types()\fP returns
  2307. \f(CWDW_DLV_OK\fP and sets \f(CW*typecount\fP to
  2308. the count of user-defined
  2309. type names represented in the section containing user-defined type names,
  2310. i.e. .debug_typenames.  
  2311. It also stores at \f(CW*types\fP, 
  2312. a pointer to a list of \f(CWDwarf_Type\fP descriptors, one for each of the 
  2313. user-defined type names in the .debug_typenames section.  
  2314. It returns \f(CWDW_DLV_NOCOUNT\fP on error. 
  2315. It returns \f(CWDW_DLV_NO_ENTRY\fP if 
  2316. the .debug_typenames section does not exist.  
  2317. On a successful 
  2318. return from this function, the \f(CWDwarf_Type\fP descriptors should be 
  2319. individually free'd using \f(CWdwarf_dealloc()\fP with the allocation type 
  2320. \f(CWDW_DLA_TYPENAME\fP, followed by the deallocation of the list itself 
  2321. with the allocation type \f(CWDW_DLA_LIST\fP when the descriptors are no 
  2322. longer of interest.
  2323.  
  2324. .in +2
  2325. .DS
  2326. \f(CWDwarf_Signed cnt;
  2327. Dwarf_Type *types;
  2328. int res;
  2329.  
  2330. if ((res = dwarf_get_types(dbg, &types,&cnt, &error)) == DW_DLV_OK) {
  2331.  
  2332.         for (i = 0; i < cnt; ++i) {
  2333.                 /* use types[i] */
  2334.                 dwarf_dealloc(dbg, types[i], DW_DLA_TYPENAME);
  2335.         }
  2336.         dwarf_dealloc(dbg, types, DW_DLA_LIST);
  2337. }\fP
  2338. .DE
  2339. .in -2
  2340.  
  2341. .DS
  2342. \f(CWint dwarf_typename(
  2343.         Dwarf_Type   type,
  2344.         char       **return_name,
  2345.         Dwarf_Error *error)\fP
  2346. .DE
  2347. The function \f(CWdwarf_typename()\fP returns
  2348. \f(CWDW_DLV_OK\fP and sets \f(CW*return_name\fP to
  2349. a pointer to a
  2350. null-terminated string that names the user-defined type represented by the
  2351. \f(CWDwarf_Type\fP descriptor, \f(CWtype\fP.  
  2352. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2353. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2354. On a successful return from this function, the string should
  2355. be free'd using \f(CWdwarf_dealloc()\fP, with the allocation type
  2356. \f(CWDW_DLA_STRING\fP when no longer of interest.
  2357.  
  2358. .DS
  2359. \f(CWint dwarf_type_die_offset(
  2360.         Dwarf_Type type,
  2361.         Dwarf_Off  *return_offset,
  2362.         Dwarf_Error *error)\fP
  2363. .DE
  2364. The function \f(CWdwarf_type_die_offset()\fP returns
  2365. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to
  2366. the offset in
  2367. the section containing DIE's, i.e. .debug_info, of the DIE representing
  2368. the user-defined type that is described by the \f(CWDwarf_Type\fP 
  2369. descriptor, \f(CWtype\fP.  
  2370. It returns \f(CWDW_DLV_ERROR\fP on error.
  2371. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2372.  
  2373. .DS
  2374. \f(CWint dwarf_type_cu_offset(
  2375.         Dwarf_Type type,
  2376.         Dwarf_Off  *return_offset,
  2377.         Dwarf_Error *error)\fP
  2378. .DE
  2379. The function \f(CWdwarf_type_cu_offset()\fP returns
  2380. \f(CWDW_DLV_OK\fP and sets \f(CW*return_offset\fP to
  2381. the offset in
  2382. the section containing DIE's, i.e. .debug_info, of the compilation-unit
  2383. header of the compilation-unit that contains the user-defined type
  2384. described by the \f(CWDwarf_Type\fP descriptor, \f(CWtype\fP.  
  2385. It returns \f(CWDW_DLV_ERROR\fP on error.
  2386. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2387.  
  2388. .DS
  2389. \f(CWint dwarf_type_name_offsets(
  2390.         Dwarf_Type   type,
  2391.         char      ** returned_name,
  2392.         Dwarf_Off *  die_offset,
  2393.         Dwarf_Off *  cu_offset,
  2394.         Dwarf_Error *error)\fP
  2395. .DE
  2396. The function \f(CWdwarf_type_name_offsets()\fP returns
  2397. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_name\fP to
  2398. a pointer to
  2399. a null-terminated string that gives the name of the user-defined
  2400. type described by the \f(CWDwarf_Type\fP descriptor \f(CWtype\fP.
  2401. It also returns in the locations
  2402. pointed to by \f(CWdie_offset\fP, and \f(CWcu_offset\fP, the offsets
  2403. of the DIE representing the user-defined type, and the compilation-unit 
  2404. header of the compilation-unit containing the user-defined type,
  2405. respectively.  
  2406. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2407. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2408. On a successful return from \f(CWdwarf_type_name_offsets()\fP
  2409. the storage pointed to by the return value should be free'd using
  2410. \f(CWdwarf_dealloc()\fP, with the allocation type \f(CWDW_DLA_STRING\fP
  2411. when no longer of interest.
  2412.  
  2413. .H 2 "User Defined Static Variable Names Operations"
  2414. This section is SGI specific and is not part of standard DWARF version 2.
  2415. .P
  2416. These functions operate on the .debug_varnames section of the debugging
  2417. information.  The .debug_varnames section contains the names of file-scope
  2418. static variables, the offsets of the \f(CWDIE\fPs that represent the 
  2419. definitions of those variables, and the offsets of the compilation-units
  2420. that contain the definitions of those variables.
  2421.  
  2422. .H 3 "Debugger Interface Operations"
  2423.  
  2424. .DS
  2425. \f(CWint dwarf_get_vars(
  2426.         Dwarf_Debug dbg,
  2427.         Dwarf_Var **vars,
  2428.         Dwarf_Signed *var_count,
  2429.         Dwarf_Error *error)\fP
  2430. .DE
  2431. The function \f(CWdwarf_get_vars()\fP returns
  2432. \f(CWDW_DLV_OK\fP and sets \f(CW*var_count\fP to
  2433. the count of file-scope
  2434. static variable names represented in the section containing file-scope 
  2435. static variable names, i.e. .debug_varnames.  
  2436. It also stores, at \f(CW*vars\fP, a pointer to a list of 
  2437. \f(CWDwarf_Var\fP descriptors, one for each of the file-scope static
  2438. variable names in the .debug_varnames section.  
  2439. It returns \f(CWDW_DLV_ERROR\fP on error.
  2440. It returns \f(CWDW_DLV_NO_ENTRY\fP if the .debug_varnames section does 
  2441. not exist.  
  2442. On a successful return 
  2443. from this function, the \f(CWDwarf_Var\fP descriptors should be individually 
  2444. free'd using \f(CWdwarf_dealloc()\fP with the allocation type 
  2445. \f(CWDW_DLA_VAR\fP, followed by the deallocation of the list itself with 
  2446. the allocation type \f(CWDW_DLA_LIST\fP when the descriptors are no 
  2447. longer of interest.
  2448.  
  2449. .in +2
  2450. .DS
  2451. \f(CWDwarf_Signed cnt;
  2452. Dwarf_Var *vars;
  2453. int res;
  2454.  
  2455. if ((res = dwarf_get_vars(dbg, &vars,&cnt &error)) == DW_DLV_OK) {
  2456.  
  2457.         for (i = 0; i < cnt; ++i) {
  2458.                 /* use vars[i] */
  2459.                 dwarf_dealloc(dbg, vars[i], DW_DLA_VAR);
  2460.         }
  2461.         dwarf_dealloc(dbg, vars, DW_DLA_LIST);
  2462. }\fP
  2463. .DE
  2464. .in -2
  2465.  
  2466. .DS
  2467. \f(CWint dwarf_varname(
  2468.         Dwarf_Var var,
  2469.         char **    returned_name,
  2470.         Dwarf_Error *error)\fP
  2471. .DE
  2472. The function \f(CWdwarf_varname()\fP returns
  2473. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_name\fP to
  2474. a pointer to a
  2475. null-terminated string that names the file-scope static variable represented 
  2476. by the \f(CWDwarf_Var\fP descriptor, \f(CWvar\fP.  
  2477. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2478. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2479. On a successful return from this function, the string should
  2480. be free'd using \f(CWdwarf_dealloc()\fP, with the allocation type
  2481. \f(CWDW_DLA_STRING\fP when no longer of interest.
  2482.  
  2483. .DS
  2484. \f(CWint dwarf_var_die_offset(
  2485.         Dwarf_Var    var,
  2486.         Dwarf_Off   *returned_offset,
  2487.         Dwarf_Error *error)\fP
  2488. .DE
  2489. The function \f(CWdwarf_var_die_offset()\fP returns
  2490. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_offset\fP to
  2491. the offset in
  2492. the section containing DIE's, i.e. .debug_info, of the DIE representing
  2493. the file-scope static variable that is described by the \f(CWDwarf_Var\fP 
  2494. descriptor, \f(CWvar\fP.  
  2495. It returns \f(CWDW_DLV_ERROR\fP on error.
  2496. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2497.  
  2498. .DS
  2499. \f(CWint dwarf_var_cu_offset(
  2500.         Dwarf_Var var,
  2501.         Dwarf_Off   *returned_offset,
  2502.         Dwarf_Error *error)\fP
  2503. .DE
  2504. The function \f(CWdwarf_var_cu_offset()\fP returns
  2505. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_offset\fP to
  2506. the offset in
  2507. the section containing DIE's, i.e. .debug_info, of the compilation-unit
  2508. header of the compilation-unit that contains the file-scope static
  2509. variable described by the \f(CWDwarf_Var\fP descriptor, \f(CWvar\fP.  
  2510. It returns \f(CWDW_DLV_ERROR\fP on error.
  2511. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2512.  
  2513. .DS
  2514. \f(CWint dwarf_var_name_offsets(
  2515.         Dwarf_Var var,
  2516.     char     **returned_name,
  2517.         Dwarf_Off *die_offset,
  2518.         Dwarf_Off *cu_offset,
  2519.         Dwarf_Error *error)\fP
  2520. .DE
  2521. The function \f(CWdwarf_var_name_offsets()\fP returns
  2522. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_name\fP to
  2523. a pointer to
  2524. a null-terminated string that gives the name of the file-scope
  2525. static variable described by the \f(CWDwarf_Var\fP descriptor \f(CWvar\fP.
  2526. It also returns in the locations
  2527. pointed to by \f(CWdie_offset\fP, and \f(CWcu_offset\fP, the offsets
  2528. of the DIE representing the file-scope static variable, and the 
  2529. compilation-unit header of the compilation-unit containing the 
  2530. file-scope static variable, respectively.  
  2531. It returns \f(CWDW_DLV_ERROR\fP on error.  
  2532. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2533. On a successful return from 
  2534. \f(CWdwarf_var_name_offsets()\fP the storage pointed to by the return 
  2535. value should be free'd using \f(CWdwarf_dealloc()\fP, with the allocation 
  2536. type \f(CWDW_DLA_STRING\fP when no longer of interest.
  2537.  
  2538. .\"#if 0
  2539. .\".H 2 "Macro Information Operations"
  2540. .\"
  2541. .\".H 3 "Debugger Interface Macro Operations"
  2542. .\"Macro information is accessed from the .debug_info section via the
  2543. .\"DW_AT_macro_info attribute (whose value is an offset into .debug_macinfo).
  2544. .\"
  2545. .\".DS
  2546. .\"\f(CWint dwarf_get_macinfo(
  2547. .\"        Dwarf_Debug        dbg,
  2548. .\"        Dwarf_Unsigned     offset
  2549. .\"        Dwarf_Macro_Info * array_of_macro_entries,
  2550. .\"        Dwarf_Signed *     entry_count,
  2551. .\"        Dwarf_Error*       error);\fP
  2552. .\".DE
  2553. .\"The function \f(CWdwarf_get_macinfo()\fP returns a count of array 
  2554. .\" FIX
  2555. .\"entries in the array-pointer returned through the pointer 
  2556. .\"\f(CWarray_of_macro_entries\fP.  This function is currently
  2557. .\"unimplemented.
  2558. .\"
  2559. .\".DS
  2560. .\"\f(CWint  dwarf_get_mac_command(
  2561. .\"        Dwarf_Macro_Info,
  2562. .\"        Dwarf_Signed index,
  2563. .\"        Dwarf_Half   * returned_command,
  2564. .\"        Dwarf_Error *error);\fP
  2565. .\".DE
  2566. .\"\f(CWdwarf_get_mac_command()\fP returns \f(CWDW_MACINFO_define\fP, 
  2567. .\" FIX
  2568. .\"\f(CWDW_MACINFO_undef\fP, \f(CWDW_MACINFO_start_file\fP,
  2569. .\"\f(CWDW_MACINFO_end_file\fP, or \f(CWDW_MACINFO_vendor_ext\fP.  It
  2570. .\"returns -1 on error.  This function is currently unimplemented.
  2571. .\"
  2572. .\".DS
  2573. .\"\f(CWint  dwarf_get_mac_line(
  2574. .\"        Dwarf_Macro_Info,
  2575. .\"        Dwarf_Signed index,
  2576. .\"        Dwarf_Signed *returned_line,
  2577. .\"        Dwarf_Error *error);\fP
  2578. .\".DE
  2579. .\"The function \f(CWdwarf_get_mac_line()\fP returns the source line number. 
  2580. .\" FIX
  2581. .\"Useful on \f(CWDW_MACINFO_start_file\fP, \f(CWDW_MACINFO_undef\fP, and 
  2582. .\"i\f(CWDW_MACINFO_define\fP.  This function is currently unimplemented.
  2583. .\"
  2584. .\".DS
  2585. .\"\f(CWint   dwarf_get_mac_string(
  2586. .\"        Dwarf_Macro_Info,
  2587. .\"        Dwarf_Signed index,
  2588. .\"        char   **   returned_string,
  2589. .\"        Dwarf_Error *error);\fP
  2590. .\".DE
  2591. .\"\f(CWdwarf_get_mac_string()\fP is returns the string value of the 
  2592. .\" FIX
  2593. .\"\f(CWDW_MACRO_define\fP or \f(CWDW_MACRO_undef\fP command.  This
  2594. .\"function is currently unimplemented.
  2595. .\"
  2596. .\".DS
  2597. .\"\f(CWint   dwarf_get_mac_filename(
  2598. .\"        Dwarf_Macro_Info,
  2599. .\"        Dwarf_Signed index,
  2600. .\"        char  ** returned_filename,
  2601. .\"        Dwarf_Error *error);\fP
  2602. .\".DE
  2603. .\"\f(CWdwarf_get_mac_filename()\fP returns the file name given in a 
  2604. .\" FIX
  2605. .\"\f(CWDW_MACINFO_start_file\fP command.  This function is currently
  2606. .\"unimplemented.
  2607. .\"
  2608. .\".H 3 "Internal-level Interface Macro Operations"
  2609. .\"Not yet defined.
  2610. .\"#endif
  2611.  
  2612. .H 2 "Low Level Frame Operations"
  2613. These functions provide information about stack frames to be
  2614. used to perform stack traces.  The information is an abstraction
  2615. of a table with a row per instruction and a column per register
  2616. and a column for the canonical frame address (CFA, which corresponds
  2617. to the frame pointer), as well as a column for the return address.  
  2618. Each cell in the table contains one of the following:
  2619.  
  2620. .AL 
  2621. .LI
  2622. A register + offset
  2623.  
  2624. .LI
  2625. A register
  2626.  
  2627. .LI
  2628. A marker (DW_FRAME_UNDEFINED_VAL) meaning \fIregister value undefined\fP
  2629.  
  2630. .LI
  2631. A marker (DW_FRAME_SAME_VAL) meaning \fIregister value same as in caller\fP
  2632. .LE
  2633.  
  2634. Figure \n(aX
  2635. is machine dependent and represents MIPS cpu register
  2636. assignments.
  2637. .DS
  2638. .TS
  2639. center box, tab(:);
  2640. lfB lfB lfB
  2641. l c l.
  2642. NAME:value:PURPOSE
  2643. _
  2644. DW_FRAME_CFA_COL:0:column used for CFA
  2645. DW_FRAME_REG1:1:integer regster 1
  2646. DW_FRAME_REG2:2:integer register 2
  2647. ---::obvious names and values here
  2648. DW_FRAME_REG30:30:integer register 30 
  2649. DW_FRAME_REG31:31:integer register 31
  2650. DW_FRAME_FREG0:32:floating point register 0
  2651. DW_FRAME_FREG1:33:floating point register 1
  2652. ---::obvious names and values here
  2653. DW_FRAME_FREG30:62:floating point register 30
  2654. DW_FRAME_FREG31:63:floating point register 31
  2655. DW_FRAME_RA_COL:64:column recording ra
  2656. DW_FRAME_UNDEFINED_VAL:1034:register val undefined
  2657. DW_FRAME_SAME_VAL:1035:register same as in caller
  2658. .TE
  2659.  
  2660. .FG "Frame Information Rule Assignments"
  2661. .DE
  2662.  
  2663. .P
  2664. The following table shows SGI/MIPS specific
  2665. special cell values: these values mean 
  2666. that the cell has the value \fIundefined\fP or \fIsame value\fP
  2667. respectively, rather than containing a \fIregister\fP or
  2668. \fIregister+offset\fP.  
  2669. .P
  2670. .DS
  2671. .TS
  2672. center box, tab(:);
  2673. lfB lfB lfB
  2674. l c l.
  2675. NAME:value:PURPOSE
  2676. _
  2677. DW_FRAME_UNDEFINED_VAL:1034:means undefined value.
  2678. ::Not a column or register value
  2679. DW_FRAME_SAME_VAL:1035:means 'same value' as
  2680. ::caller had. Not a column or 
  2681. ::register value
  2682. .TE
  2683. .FG "Frame Information Special Values"
  2684. .DE
  2685.  
  2686. .\"#if 0
  2687. .\".P
  2688. .\"Since the cie and fde entries are not "organized" by anything
  2689. .\"outside of the .debug_frame section one must scan them all to 
  2690. .\"find all entry addresses and lengths.  Since there is one fde 
  2691. .\"per function this can be a rather long list.
  2692. .\"#endif
  2693.  
  2694. .P
  2695. .DS
  2696. \f(CWint dwarf_get_fde_list(
  2697.         Dwarf_Debug dbg,
  2698.         Dwarf_Cie **cie_data,
  2699.         Dwarf_Signed *cie_element_count,
  2700.         Dwarf_Fde **fde_data,
  2701.         Dwarf_Signed *fde_element_count,
  2702.         Dwarf_Error *error);\fP
  2703. .DE
  2704. \f(CWdwarf_get_fde_list()\fP stores a pointer to a list of 
  2705. \f(CWDwarf_Cie\fP descriptors in \f(CW*cie_data\fP, and the 
  2706. count of the number of descriptors in \f(CW*cie_element_count\fP.  
  2707. There is a descriptor for each CIE in the .debug_frame section.  
  2708. Similarly, it stores a pointer to a list of \f(CWDwarf_Fde\fP 
  2709. descriptors in \f(CW*fde_data\fP, and the count of the number 
  2710. of descriptors in \f(CW*fde_element_count\fP.  There is one 
  2711. descriptor per FDE in the .debug_frame section.  
  2712. \f(CWdwarf_get_fde_list()\fP  returns \f(CWDW_DLV_EROR\fP on error.
  2713. It returns \f(CWDW_DLV_NO_ENTRY\fP if it cannot find frame entries.
  2714. It returns \f(CWDW_DLV_OK\fP on a successful return.
  2715.  
  2716. On successful return, each of the structures pointed to by a 
  2717. descriptor should be individually free'd using \f(CWdwarf_dealloc()\fP 
  2718. with either the allocation type \f(CWDW_DLA_CIE\fP, or \f(CWDW_DLA_FDE\fP 
  2719. as appropriate when no longer of interest.  Each of the blocks 
  2720. of descriptors should be free'd using \f(CWdwarf_dealloc()\fP with 
  2721. the allocation type \f(CWDW_DLA_LIST\fP when no longer of interest.
  2722.  
  2723.  
  2724. .in +2
  2725. .DS
  2726. \f(CWDwarf_Signed cnt;
  2727. Dwarf_Cie *cie_data;
  2728. Dwarf_Signed cie_count;
  2729. Dwarf_Fde *fde_data;
  2730. Dwarf_Signed fde_count;
  2731. int fres;
  2732.  
  2733. if ((fres = dwarf_get_fde_list(dbg,&cie_data,&cie_count, 
  2734.         &fde_data,&fde_count,&error)) == DW_DLV_OK) {
  2735.  
  2736.         for (i = 0; i < cie_count; ++i) {
  2737.                 /* use cie[i] */
  2738.                 dwarf_dealloc(dbg, cie_data[i], DW_DLA_CIE);
  2739.         }
  2740.         for (i = 0; i < fde_count; ++i) {
  2741.                 /* use fde[i] */
  2742.                 dwarf_dealloc(dbg, fde_data[i], DW_DLA_FDE);
  2743.         }
  2744.         dwarf_dealloc(dbg, cie_data, DW_DLA_LIST);
  2745.         dwarf_dealloc(dbg, fde_data, DW_DLA_LIST);
  2746. }\fP
  2747. .DE
  2748. .in -2
  2749.  
  2750. .P
  2751. Each \f(CWDwarf_Fde\fP descriptor describes information about the
  2752. frame for a particular subroutine or function.
  2753.  
  2754. \f(CWint dwarf_get_fde_for_die\fPis SGI/MIPS specific.
  2755.  
  2756. .DS
  2757. \f(CWint dwarf_get_fde_for_die(
  2758.         Dwarf_Debug dbg,
  2759.         Dwarf_Die die,
  2760.         Dwarf_Fde *  return_fde,
  2761.         Dwarf_Error *error)\fP
  2762. .DE
  2763. When it succeeds,
  2764. \f(CWdwarf_get_fde_for_die()\fP returns 
  2765. \f(CWDW_DLV_OK\fP and sets \f(CW*return_fde\fP
  2766. to
  2767. a \f(CWDwarf_Fde\fP
  2768. descriptor representing frame information for the given \f(CWdie\fP.  It 
  2769. looks for the \f(CWDW_AT_MIPS_fde\fP attribute in the given \f(CWdie\fP.
  2770. If it finds it, is uses the value of the attribute as the offset in 
  2771. the .debug_frame section where the FDE begins.
  2772. If there is no \f(CWDW_AT_MIPS_fde\fP it returns \f(CWDW_DLV_NO_ENTRY\fP.
  2773. If there is an error it returns \f(CWDW_DLV_ERROR\fP.
  2774.  
  2775. .DS
  2776. \f(CWint dwarf_get_fde_range(
  2777.         Dwarf_Fde fde,
  2778.         Dwarf_Addr *low_pc,
  2779.         Dwarf_Unsigned *func_length,
  2780.         Dwarf_Ptr *fde_bytes,
  2781.         Dwarf_Unsigned *fde_byte_length,
  2782.         Dwarf_Off *cie_offset,
  2783.         Dwarf_Signed *cie_index,
  2784.         Dwarf_Off *fde_offset,
  2785.         Dwarf_Error *error);\fP
  2786. .DE
  2787. On success,
  2788. \f(CWdwarf_get_fde_range()\fP returns
  2789. \f(CWDW_DLV_OK\fP.
  2790. The location pointed to by \f(CWlow_pc\fP is set to the low pc value for
  2791. this function.  
  2792. The location pointed to by \f(CWfunc_length\fP is 
  2793. set to the length of the function in bytes.  
  2794. This is essentially the
  2795. length of the text section for the function.  
  2796. The location pointed
  2797. to by \f(CWfde_bytes\fP is set to the address where the FDE begins
  2798. in the .debug_frame section.  
  2799. The location pointed to by 
  2800. \f(CWfde_byte_length\fP is set to the length in bytes of the portion
  2801. of .debug_frame for this FDE.  
  2802. This is the same as the value returned
  2803. by \f(CWdwarf_get_fde_range\fP.  
  2804. The location pointed to by 
  2805. \f(CWcie_offset\fP is set to the offset in the .debug_frame section
  2806. of the CIE used by this FDE.  
  2807. The location pointed to by \f(CWcie_index\fP
  2808. is set to the index of the CIE used by this FDE.  
  2809. The index is the 
  2810. index of the CIE in the list pointed to by \f(CWcie_data\fP as set 
  2811. by the function \f(CWdwarf_get_fde_list()\fP.  
  2812. However, if the function
  2813. \f(CWdwarf_get_fde_for_die()\fP was used to obtain the given \f(CWfde\fP, 
  2814. this index may not be correct.   
  2815. The location pointed to by 
  2816. \f(CWfde_offset\fP is set to the offset of the start of this FDE in 
  2817. the .debug_frame section.  
  2818. \f(CWdwarf_get_fde_range()\fP returns \f(CWDW_DLV_ERROR\fP on error.
  2819.  
  2820. .DS
  2821. \f(CWint dwarf_get_cie_info(
  2822.         Dwarf_Cie       cie,
  2823.     Dwarf_Unsigned *bytes_in_cie,
  2824.         Dwarf_Small    *version,
  2825.         char          **augmenter,
  2826.         Dwarf_Unsigned *code_alignment_factor,
  2827.         Dwarf_Signed *data_alignment_factor,
  2828.         Dwarf_Half     *return_address_register_rule,
  2829.         Dwarf_Ptr      *initial_instructions,
  2830.         Dwarf_Unsigned *initial_instructions_length,
  2831.         Dwarf_Error    *error);\fP
  2832. .DE
  2833. \f(CWdwarf_get_cie_info()\fP is primarily for Internal-level Interface 
  2834. consumers.  
  2835. If successful,
  2836. it returns
  2837. \f(CWDW_DLV_OK\fP and sets \f(CW*bytes_in_cie\fP to
  2838. the number of bytes in the portion of the
  2839. frames section for the CIE represented by the given \f(CWDwarf_Cie\fP
  2840. descriptor, \f(CWcie\fP.  
  2841. The other fields are directly taken from 
  2842. the cie and returned, via the pointers to the caller.  
  2843. It returns \f(CWDW_DLV_ERROR\fP on error.
  2844.  
  2845. .DS
  2846. \f(CWint dwarf_get_fde_info_for_reg(
  2847.         Dwarf_Fde fde,
  2848.         Dwarf_Half table_column,
  2849.         Dwarf_Addr pc_requested,
  2850.     Dwarf_Signed *offset_relevant,
  2851.         Dwarf_Signed *register_num,
  2852.         Dwarf_Signed *offset,
  2853.         Dwarf_Addr *row_pc,
  2854.         Dwarf_Error *error);\fP
  2855. .DE
  2856. \f(CWdwarf_get_fde_info_for_reg()\fP returns
  2857. \f(CWDW_DLV_OK\fP and sets \f(CW*offset_relevant\fP to
  2858. non-zero if the offset is relevant for the
  2859. row specified by \f(CWpc_requested\fP and column specified by
  2860. \f(CWtable_column\fP, for the FDE specified by \f(CWfde\fP.  
  2861. The
  2862. intent is to return the rule for the given pc value and register.
  2863. The location pointed to by \f(CWregister_num\fP is set to the register
  2864. value for the rule.  
  2865. The location pointed to by \f(CWoffset\fP 
  2866. is set to the offset value for the rule.  
  2867. If offset is not relevant for this rule, \f(CW*offset_relevant\fP is
  2868. set to zero.
  2869. Since more than one pc 
  2870. value will have rows with identical entries, the user may want to
  2871. know the earliest pc value after which the rules for all the columns
  2872. remained unchanged.  
  2873. Recall that in the virtual table that the frame information
  2874. represents there may be one or more table rows with identical data
  2875. (each such table row at a different pc value).
  2876. Given a \f(CWpc_requested\fP which refers to a pc in such a group
  2877. of identical rows, 
  2878. the location pointed to by \f(CWrow_pc\fP is set 
  2879. to the lowest pc value
  2880. within the group of  identical rows.
  2881. The  value put in \f(CW*register_num\fP any of the
  2882. \f(CWDW_FRAME_*\fP table columns values specified in \f(CWlibdwarf.h\fP
  2883. or \f(CWdwarf.h\fP.
  2884.  
  2885. \f(CWdwarf_get_fde_info_for_reg\fP returns \f(CWDW_DLV_ERROR\fP if there is an error. 
  2886.  
  2887. It is usable with either 
  2888. \f(CWdwarf_get_fde_n()\fP or \f(CWdwarf_get_fde_at_pc()\fP.
  2889.  
  2890. .DS
  2891. \f(CWint   dwarf_get_fde_n(
  2892.         Dwarf_Fde *fde_data,
  2893.         Dwarf_Unsigned fde_index,
  2894.     Dwarf_Fde      *returned_fde
  2895.         Dwarf_Error *error);\fP
  2896. .DE
  2897. \f(CWdwarf_get_fde_n()\fP returns
  2898. \f(CWDW_DLV_OK\fP and sets \f(CWreturned_fde\fP to
  2899. the \f(CWDwarf_Fde\fP descriptor whose 
  2900. index is \f(CWfde_index\fP in the table of \f(CWDwarf_Fde\fP descriptors
  2901. pointed to by \fPfde_data\fP.  
  2902. The index starts with 0.  
  2903. Returns \f(CWDW_DLV_NO_ENTRY\fP if the index does not 
  2904. exist in the table of \f(CWDwarf_Fde\fP 
  2905. descriptors. 
  2906. Returns \f(CWDW_DLV_ERROR\fP if there is an error.
  2907. This function cannot be used unless
  2908. the block of \f(CWDwarf_Fde\fP descriptors has been created by a call to
  2909. \f(CWdwarf_get_fde_list()\fP.
  2910.  
  2911. .DS
  2912. \f(CWint   dwarf_get_fde_at_pc(
  2913.         Dwarf_Fde *fde_data,
  2914.         Dwarf_Addr pc_of_interest,
  2915.         Dwarf_Fde *returned_fde,
  2916.         Dwarf_Addr *lopc,
  2917.         Dwarf_Addr *hipc,
  2918.         Dwarf_Error *error);\fP
  2919. .DE
  2920. \f(CWdwarf_get_fde_at_pc()\fP returns
  2921. \f(CWDW_DLV_OK\fP and sets \f(CWreturned_fde\fP to
  2922. a \f(CWDwarf_Fde\fP descriptor
  2923. for a function which contains the pc value specified by \f(CWpc_of_interest\fP.
  2924. In addition, it sets the locations pointed to 
  2925. by \f(CWlopc\fP and \f(CWhipc\fP to the low address and the high address 
  2926. covered by this FDE, respectively.  
  2927. It returns \f(CWDW_DLV_ERROR\fP on error.
  2928. It returns \f(CWDW_DLV_NO_ENTRY\fP 
  2929. if \f(CWpc_of_interest\fP is not in any of the
  2930. FDEs represented by the block of \f(CWDwarf_Fde\fP descriptors pointed
  2931. to by \f(CWfde_data\fP.  
  2932. This function cannot be used unless
  2933. the block of \f(CWDwarf_Fde\fP descriptors has been created by a call to
  2934. \f(CWdwarf_get_fde_list()\fP.
  2935.  
  2936. .DS
  2937. \f(CWint dwarf_expand_frame_instructions(
  2938.         Dwarf_Debug dbg,
  2939.         Dwarf_Ptr instruction,
  2940.         Dwarf_Unsigned i_length,
  2941.         Dwarf_Frame_Op **returned_op_list,
  2942.         Dwarf_Signed   * returned_op_count,
  2943.         Dwarf_Error *error);\fP
  2944. .DE
  2945. \f(CWdwarf_expand_frame_instructions()\fP is a High-level interface 
  2946. function which expands a frame instruction byte stream into an 
  2947. array of \f(CWDwarf_Frame_Op\fP structures.  
  2948. To indicate success, it returns \f(CWDW_DLV_OK\fP.
  2949. The address where 
  2950. the byte stream begins is specified by \f(CWinstruction\fP, and
  2951. the length of the byte stream is specified by \f(CWi_length\fP.
  2952. The location pointed to by \f(CWreturned_op_list\fP is set to
  2953. point to a table of 
  2954. \f(CWreturned_op_count\fP
  2955. pointers to \f(CWDwarf_Frame_Op\fP which
  2956. contain the frame instructions in the byte stream.  
  2957. It returns \f(CWDW_DLV_ERROR\fP on error. 
  2958. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  2959. After a successful return, the
  2960. array of structures should be freed using
  2961. \f(CWdwarf_dealloc()\fP with the allocation type \f(CWDW_DLA_FRAME_BLOCK\fP
  2962. (when they are no longer of interest).
  2963.  
  2964. .in +2
  2965. .DS
  2966. \f(CWDwarf_Signed cnt;
  2967. Dwarf_Frame_Op *frameops;
  2968. Dwarf_Ptr instruction;
  2969. Dwarf_Unsigned len;
  2970. int res;
  2971.  
  2972. if (expand_frame_instructions(dbg,instruction,len, &frameops,&cnt, &error)
  2973.          == DW_DLV_OK) {
  2974.  
  2975.         for (i = 0; i < cnt; ++i) {
  2976.                 /* use frameops[i] */
  2977.         }
  2978.         dwarf_dealloc(dbg, frameops, DW_DLA_FRAME_BLOCK);
  2979. }\fP
  2980. .DE
  2981. .in -2
  2982.  
  2983.  
  2984. .H 2 "Location Expression Evaluation"
  2985.  
  2986. An "interpreter" which evaluates a location expression
  2987. is required in any debugger.  There is no interface defined
  2988. here at this time.  
  2989.  
  2990. .P
  2991. One problem with defining an interface is that operations are
  2992. machine dependent: they depend on the interpretation of
  2993. register numbers and the methods of getting values from the
  2994. environment the expression is applied to.
  2995.  
  2996. .P
  2997. It would be desirable to specify an interface.
  2998.  
  2999. .H 3 "Location List Internal-level Interface"
  3000.  
  3001. .DS
  3002. \f(CWint dwarf_get_loclist_entry(
  3003.         Dwarf_Debug dbg,
  3004.         Dwarf_Unsigned offset,
  3005.         Dwarf_Addr *hipc_offset,
  3006.         Dwarf_Addr *lopc_offset,
  3007.         Dwarf_Ptr *data,
  3008.         Dwarf_Unsigned *entry_len,
  3009.         Dwarf_Unsigned *next_entry,
  3010.         Dwarf_Error *error)\fP
  3011. .DE
  3012. \f(CWdwarf_dwarf_get_loclist_entry()\fP returns 
  3013. \f(CWDW_DLV_OK\fP if successful.
  3014. \f(CWDW_DLV_ERROR\fP is returned on error. 
  3015. The function reads 
  3016. a location list entry starting at \f(CWoffset\fP and returns 
  3017. through pointers (when successful)
  3018. the high pc \f(CWhipc_offset\fP, low pc 
  3019. \f(CWlopc_offset\fP, a pointer to the location description data 
  3020. \f(CWdata\fP, the length of the location description data 
  3021. \f(CWentry_len\fP, and the offset of the next location description 
  3022. entry \f(CWnext_entry\fP.  
  3023. When \f(CWhipc\fP and \f(CWlopc\fP are 
  3024. zero, this is the end of a particular location list.  
  3025.  
  3026. .P
  3027. The \f(CWhipc_offset\fP,
  3028. low pc \f(CWlopc_offset\fP are offsets from the beginning of the
  3029. current procedure, not genuine pc values.
  3030.  
  3031. .H 2 "Abbreviations access"
  3032. These are Internal-level Interface functions.  
  3033. Debuggers can ignore this.
  3034.  
  3035. .DS
  3036. \f(CWint dwarf_get_abbrev(
  3037.         Dwarf_Debug dbg,
  3038.         Dwarf_Unsigned offset,
  3039.         Dwarf_Abbrev   *returned_abbrev,
  3040.         Dwarf_Unsigned *length,
  3041.         Dwarf_Unsigned *attr_count,
  3042.         Dwarf_Error *error)\fP
  3043. .DE
  3044. The function \f(CWdwarf_get_abbrev()\fP returns
  3045. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_fde\fP to
  3046. \f(CWDwarf_Abbrev\fP 
  3047. descriptor for an abbreviation at offset \f(CW*offset\fP in the abbreviations 
  3048. section (i.e .debug_abbrev) on success.  
  3049. The user is responsible for making sure that 
  3050. a valid abbreviation begins at \f(CWoffset\fP in the abbreviations section.  
  3051. The location pointed to by \f(CWlength\fP 
  3052. is set to the length in bytes of the abbreviation in the abbreviations 
  3053. section.  
  3054. The location pointed to by \f(CWattr_count\fP is set to the 
  3055. number of attributes in the abbreviation.  
  3056. An abbreviation entry with a 
  3057. length of 1 is the 0 byte of the last abbreviation entry of a compilation 
  3058. unit.
  3059. \f(CWdwarf_get_abbrev()\fP returns \f(CWDW_DLV_ERROR\fP on error.  
  3060.  
  3061. .DS
  3062. \f(CWint dwarf_get_abbrev_tag(
  3063.         Dwarf_abbrev abbrev,
  3064.     Dwarf_Half   return_tag,
  3065.         Dwarf_Error *error);\P
  3066. .DE
  3067. If successfull,
  3068. \f(CWdwarf_get_abbrev_tag()\fP returns
  3069. \f(CWDW_DLV_OK\fP and sets \f(CW*return_tag\fP to
  3070. the \fItag\fP of 
  3071. the given abbreviation.
  3072. It returns \f(CWDW_DLV_ERROR\fP on error.
  3073. It never returns \f(CWDW_DLV_NO_ENTRY\fP.
  3074.  
  3075. .DS
  3076. \f(CWint dwarf_get_abbrev_children_flag(
  3077.         Dwarf_Abbrev abbrev,
  3078.     Dwarf_Signed  *returned_flag,
  3079.         Dwarf_Error *error)\fP
  3080. .DE
  3081. The function \f(CWdwarf_get_abbrev_children_flag()\fP returns 
  3082. \f(CWDW_DLV_OK\fP and sets \f(CWreturned_flag\fP to
  3083. \f(CWDW_children_no\fP (if the given abbreviation indicates that 
  3084. a die with that abbreviation has no children) or 
  3085. \f(CWDW_children_yes\fP (if the given abbreviation indicates that 
  3086. a die with that abbreviation has a child).  
  3087. It returns \f(CWDW_DLV_ERROR\fP on error.
  3088.  
  3089. .DS
  3090. \f(CWint dwarf_get_abbrev_entry(
  3091.         Dwarf_Abbrev abbrev,
  3092.         Dwarf_Signed index,
  3093.         Dwarf_Half   *attr_num,
  3094.         Dwarf_Signed *form,
  3095.         Dwarf_Off *offset,
  3096.         Dwarf_Error *error)\fP
  3097.  
  3098. .DE
  3099. If successful,
  3100. \f(CWdwarf_get_abbrev_entry()\fP returns
  3101. \f(CWDW_DLV_OK\fP and sets \f(CW*attr_num\fP to the attribute code of
  3102. the attribute 
  3103. whose index is specified by \f(CWindex\fP in the given abbreviation.  
  3104. The index starts at 0.  
  3105. The location pointed to by \f(CWform\fP is set 
  3106. to the form of the attribute.  
  3107. The location pointed to by \f(CWoffset\fP 
  3108. is set to the byte offset of the attribute in the abbreviations section.  
  3109. It returns \f(CWDW_DLV_NO_ENTRY\fP if the index specified is outside
  3110. the range of attributes in this abbreviation.
  3111. It returns \f(CWDW_DLV_ERROR\fP on error.
  3112.  
  3113. .H 2 "String Section Operations"
  3114. The .debug_str section contains only strings.  Debuggers need 
  3115. never use this interface: it is only for debugging problems with 
  3116. the string section itself.  
  3117.  
  3118. .DS
  3119. \f(CWint dwarf_get_str(
  3120.         Dwarf_Debug   dbg,
  3121.         Dwarf_Off     offset,
  3122.         char        **string,
  3123.     Dwarf_Signed  returned_str_len,
  3124.         Dwarf_Error *error)\fP
  3125. .DE
  3126. The function \f(CWdwarf_get_str()\fP returns
  3127. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_str_len\fP to
  3128. the length of 
  3129. the string, not counting the null terminator, that begins at the offset 
  3130. specified by \f(CWoffset\fP in the .debug_str section.  
  3131. The location 
  3132. pointed to by \f(CWstring\fP is set to a pointer to this string.
  3133. The next string in the .debug_str
  3134. section begins at the previous \f(CWoffset\fP + 1 + \f(CW*returned_str_len\fP.
  3135. A zero-length string is NOT the end of the section.
  3136. If there is no .debug_str section, \f(CWDW_DLV_NO_ENTRY\fP is returned.
  3137. If there is an error, \f(CWDW_DLV_ERROR\fP is returned.
  3138.  
  3139. .H 2 "Address Range Operations"
  3140. These functions provide information about address ranges.  Address
  3141. ranges map ranges of pc values to the corresponding compilation-unit
  3142. die that covers the address range.
  3143.  
  3144. .DS
  3145. \f(CWint dwarf_get_aranges(
  3146.         Dwarf_Debug dbg,
  3147.         Dwarf_Arange **aranges,
  3148.         Dwarf_Signed * returned_arange_count,
  3149.         Dwarf_Error *error)\fP
  3150. .DE
  3151. The function \f(CWdwarf_get_aranges()\fP returns 
  3152. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_arange_count\fP to
  3153. the count of the
  3154. number of address ranges in the .debug_aranges section.  
  3155. It sets
  3156. \f(CW*aranges\fP to point to a block of \f(CWDwarf_Arange\fP 
  3157. descriptors, one for each address range.  
  3158. It returns \f(CWDW_DLV_ERROR\fP on error.
  3159. It returns \f(CWDW_DLV_NO_ENTRY\fP if there is no .debug_aranges
  3160. section.
  3161.  
  3162. .in +2
  3163. .DS
  3164. \f(CWDwarf_Signed cnt;
  3165. Dwarf_Arange *arang;
  3166.  
  3167. if ((dwarf_get_aranges(dbg, &arang,&cnt, &error)) == DW_DLV_OK) {
  3168.  
  3169.         for (i = 0; i < cnt; ++i) {
  3170.                 /* use arang[i] */
  3171.                 dwarf_dealloc(dbg, arang[i], DW_DLA_ARANGE);
  3172.         }
  3173.         dwarf_dealloc(dbg, arang, DW_DLA_LIST);
  3174. }\fP
  3175. .DE
  3176. .in -2
  3177.  
  3178.  
  3179. .DS
  3180. \f(CWint dwarf_get_arange(
  3181.         Dwarf_Arange *aranges,
  3182.         Dwarf_Unsigned arange_count,
  3183.         Dwarf_Addr address,
  3184.     Dwarf_Arange   *returned_arange,
  3185.         Dwarf_Error *error)\fP
  3186. .DE
  3187. The function \f(CWdwarf_get_arange()\fP takes as input a pointer 
  3188. to a block of \f(CWDwarf_Arange\fP pointers, and a count of the
  3189. number of descriptors in the block.  
  3190. It then searches for the
  3191. descriptor that covers the given \f(CWaddress\fP.  
  3192. If it finds
  3193. one, it returns
  3194. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_arange\fP to
  3195. the descriptor. 
  3196. It returns \f(CWDW_DLV_ERROR\fP on error.
  3197. It returns \f(CWDW_DLV_NO_ENTRY\fP if there is no .debug_aranges
  3198. entry covering that address.
  3199.  
  3200.  
  3201. .DS
  3202. \f(CWDwarf_Off dwarf_get_cu_die_offset(
  3203.         Dwarf_Arange arange,
  3204.         Dwarf_Off   *returned_offset,
  3205.         Dwarf_Error *error)\fP
  3206. .DE
  3207. The function \f(CWdwarf_get_cu_die_offset()\fP takes a
  3208. \f(CWDwarf_Arange\fP descriptor as input, and 
  3209. if successful returns
  3210. \f(CWDW_DLV_OK\fP and sets \f(CW*returned_offset\fP to
  3211. the offset
  3212. in the .debug_info section of the compilation-unit DIE for the 
  3213. compilation-unit represented by the given address range.
  3214. It returns \f(CWDW_DLV_ERROR\fP on error.
  3215.  
  3216. .DS
  3217. \f(CWint dwarf_get_arange_info(
  3218.         Dwarf_Arange arange,
  3219.         Dwarf_Addr *start,
  3220.         Dwarf_Unsigned *length,
  3221.         Dwarf_Off *cu_die_offset,
  3222.         Dwarf_Error *error)\fP
  3223. .DE
  3224. The function \f(CWdwarf_get_arange_info()\fP returns
  3225. \f(CWDW_DLV_OK\fP
  3226. and
  3227. stores the starting value of the address range in the location pointed 
  3228. to by \f(CWstart\fP, the length of the address range in the location 
  3229. pointed to by \f(CWlength\fP, and the offset in the .debug_info section 
  3230. of the compilation-unit DIE for the compilation-unit represented by the 
  3231. address range.
  3232. It returns \f(CWDW_DLV_ERROR\fP on error.
  3233.  
  3234. .H 2 "Utility Operations"
  3235. These functions aid in the management of errors encountered when using 
  3236. functions in the \fIlibdwarf\fP library and releasing memory allocated 
  3237. as a result of a \fIlibdwarf\fP operation. 
  3238.  
  3239. .DS
  3240. \f(CWDwarf_Unsigned dwarf_errno(
  3241.         Dwarf_Error error)\fP
  3242. .DE
  3243. The function \f(CWdwarf_errno()\fP returns the error number corresponding 
  3244. to the error specified by \f(CWerror\fP.
  3245.  
  3246. .DS
  3247. \f(CWconst char* dwarf_errmsg(
  3248.         Dwarf_Error error)\fP
  3249. .DE
  3250. The function \f(CWdwarf_errmsg()\fP returns a pointer to a
  3251. null-terminated error message string corresponding to the error specified by 
  3252. \f(CWerror\fP.  
  3253. The string returned by \f(CWdwarf_errmsg()\fP 
  3254. should not be deallocated using \f(CWdwarf_dealloc()\fP.
  3255.  
  3256. .P
  3257. The set of errors 
  3258. enumerated in Figure \n(aX below were defined in Dwarf 1.
  3259. These errors are not used by the current implementation
  3260. of Dwarf 2.  
  3261. .DS
  3262. .TS
  3263. center box, tab(:);
  3264. lfB lfB 
  3265. l l.
  3266. SYMBOLIC NAME:DESCRIPTION
  3267. _
  3268. DW_DLE_NE:No error (0)
  3269. DW_DLE_VMM:Version of DWARF information newer than libdwarf
  3270. DW_DLE_MAP:Memory map failure
  3271. DW_DLE_LEE:Propagation of libelf error
  3272. DW_DLE_NDS:No debug section
  3273. DW_DLE_NLS:No line section
  3274. DW_DLE_ID:Requested information not associated with descriptor
  3275. DW_DLE_IOF:I/O failure
  3276. DW_DLE_MAF:Memory allocation failure
  3277. DW_DLE_IA:Invalid argument
  3278. DW_DLE_MDE:Mangled debugging entry
  3279. DW_DLE_MLE:Mangled line number entry
  3280. DW_DLE_FNO:File descriptor does not refer to an open file
  3281. DW_DLE_FNR:File is not a regular file
  3282. DW_DLE_FWA:File is opened with wrong access
  3283. DW_DLE_NOB:File is not an object file
  3284. DW_DLE_MOF:Mangled object file header
  3285. DW_DLE_EOLL:End of location list entries
  3286. DW_DLE_NOLL:No location list section
  3287. DW_DLE_BADOFF:Invalid offset
  3288. DW_DLE_EOS:End of section
  3289. DW_DLE_ATRUNC:Abbreviations section appears truncated
  3290. DW_DLE_BADBITC:Address size passed to dwarf bad
  3291. .TE
  3292. .FG "List of Dwarf Error Codes"
  3293. .DE
  3294.  
  3295. The set of errors returned by SGI \f(CWLibdwarf\fP functions
  3296. is listed below.
  3297. Some of the errors are SGI specific.
  3298.  
  3299. .DS
  3300. .TS
  3301. center box, tab(:);
  3302. lfB lfB
  3303. l l.
  3304. SYMBOLIC NAME:DESCRIPTION
  3305. _
  3306. DW_DLE_DBG_ALLOC:Could not allocate Dwarf_Debug struct
  3307. DW_DLE_FSTAT_ERROR:Error in fstat()-ing object
  3308. DW_DLE_FSTAT_MODE_ERROR:Error in mode of object file
  3309. DW_DLE_INIT_ACCESS_WRONG:Incorrect access to dwarf_init()
  3310. DW_DLE_ELF_BEGIN_ERROR:Error in elf_begin() on object
  3311. DW_DLE_ELF_GETEHDR_ERROR:Error in elf_getehdr() on object
  3312. DW_DLE_ELF_GETSHDR_ERROR:Error in elf_getshdr() on object
  3313. DW_DLE_ELF_STRPTR_ERROR:Error in elf_strptr() on object
  3314. DW_DLE_DEBUG_INFO_DUPLICATE:Multiple .debug_info sections
  3315. DW_DLE_DEBUG_INFO_NULL:No data in .debug_info section
  3316. DW_DLE_DEBUG_ABBREV_DUPLICATE:Multiple .debug_abbrev sections
  3317. DW_DLE_DEBUG_ABBREV_NULL:No data in .debug_abbrev section
  3318. DW_DLE_DEBUG_ARANGES_DUPLICATE:Multiple .debug_arange sections
  3319. DW_DLE_DEBUG_ARANGES_NULL:No data in .debug_arange section
  3320. DW_DLE_DEBUG_LINE_DUPLICATE:Multiple .debug_line sections
  3321. DW_DLE_DEBUG_LINE_NULL:No data in .debug_line section
  3322. DW_DLE_DEBUG_LOC_DUPLICATE:Multiple .debug_loc sections
  3323. DW_DLE_DEBUG_LOC_NULL:No data in .debug_loc section
  3324. DW_DLE_DEBUG_MACINFO_DUPLICATE:Multiple .debug_macinfo sections
  3325. DW_DLE_DEBUG_MACINFO_NULL:No data in .debug_macinfo section
  3326. DW_DLE_DEBUG_PUBNAMES_DUPLICATE:Multiple .debug_pubnames sections
  3327. DW_DLE_DEBUG_PUBNAMES_NULL:No data in .debug_pubnames section
  3328. DW_DLE_DEBUG_STR_DUPLICATE:Multiple .debug_str sections
  3329. DW_DLE_DEBUG_STR_NULL:No data in .debug_str section
  3330. DW_DLE_CU_LENGTH_ERROR:Length of compilation-unit bad
  3331. DW_DLE_VERSION_STAMP_ERROR:Incorrect Version Stamp
  3332. DW_DLE_ABBREV_OFFSET_ERROR:Offset in .debug_abbrev bad
  3333. DW_DLE_ADDRESS_SIZE_ERROR:Size of addresses in target bad
  3334. DW_DLE_DEBUG_INFO_PTR_NULL:Pointer into .debug_info in DIE null
  3335. DW_DLE_DIE_NULL:Null Dwarf_Die
  3336. DW_DLE_STRING_OFFSET_BAD:Offset in .debug_str bad
  3337. DW_DLE_DEBUG_LINE_LENGTH_BAD:Length of .debug_line segment bad
  3338. DW_DLE_LINE_PROLOG_LENGTH_BAD:Length of .debug_line prolog bad
  3339. DW_DLE_LINE_NUM_OPERANDS_BAD:Number of operands to line instr bad
  3340. DW_DLE_LINE_SET_ADDR_ERROR:Error in DW_LNE_set_address instruction
  3341. DW_DLE_LINE_EXT_OPCODE_BAD:Error in DW_EXTENDED_OPCODE instruction
  3342. DW_DLE_DWARF_LINE_NULL:Null Dwarf_line argument
  3343. DW_DLE_INCL_DIR_NUM_BAD:Error in included directory for given line
  3344. DW_DLE_LINE_FILE_NUM_BAD:File number in .debug_line bad
  3345. DW_DLE_ALLOC_FAIL:Failed to allocate required structs
  3346. DW_DLE_DBG_NULL:Null Dwarf_Debug argument
  3347. DW_DLE_DEBUG_FRAME_LENGTH_BAD:Error in length of frame
  3348. DW_DLE_FRAME_VERSION_BAD:Bad version stamp for frame
  3349. DW_DLE_CIE_RET_ADDR_REG_ERROR:Bad register specified for return address
  3350. DW_DLE_FDE_NULL:Null Dwarf_Fde argument
  3351. DW_DLE_FDE_DBG_NULL:No Dwarf_Debug associated with FDE
  3352. DW_DLE_CIE_NULL:Null Dwarf_Cie argument
  3353. DW_DLE_CIE_DBG_NULL:No Dwarf_Debug associated with CIE
  3354. DW_DLE_FRAME_TABLE_COL_BAD:Bad column in frame table specified
  3355. .TE
  3356. .FG "List of Dwarf 2 Error Codes (contd.)"
  3357. .DE
  3358.  
  3359. .DS
  3360. .TS
  3361. center box, tab(:);
  3362. lfB lfB
  3363. l l.
  3364. SYMBOLIC NAME:DESCRIPTION
  3365. _
  3366. DW_DLE_PC_NOT_IN_FDE_RANGE:PC requested not in address range of FDE
  3367. DW_DLE_CIE_INSTR_EXEC_ERROR:Error in executing instructions in CIE
  3368. DW_DLE_FRAME_INSTR_EXEC_ERROR:Error in executing instructions in FDE
  3369. DW_DLE_FDE_PTR_NULL:Null Pointer to Dwarf_Fde specified
  3370. DW_DLE_RET_OP_LIST_NULL:No location to store pointer to Dwarf_Frame_Op
  3371. DW_DLE_LINE_CONTEXT_NULL:Dwarf_Line has no context
  3372. DW_DLE_DBG_NO_CU_CONTEXT:dbg has no CU context for dwarf_siblingof()
  3373. DW_DLE_DIE_NO_CU_CONTEXT:Dwarf_Die has no CU context
  3374. DW_DLE_FIRST_DIE_NOT_CU:First DIE in CU not DW_TAG_compilation_unit
  3375. DW_DLE_NEXT_DIE_PTR_NULL:Error in moving to next DIE in .debug_info
  3376. DW_DLE_DEBUG_FRAME_DUPLICATE:Multiple .debug_frame sections
  3377. DW_DLE_DEBUG_FRAME_NULL:No data in .debug_frame section
  3378. DW_DLE_ABBREV_DECODE_ERROR:Error in decoding abbreviation
  3379. DW_DLE_DWARF_ABBREV_NULL:Null Dwarf_Abbrev specified
  3380. DW_DLE_ATTR_NULL:Null Dwarf_Attribute specified
  3381. DW_DLE_DIE_BAD:DIE bad
  3382. DW_DLE_DIE_ABBREV_BAD:No abbreviation found for code in DIE
  3383. DW_DLE_ATTR_FORM_BAD:Inappropriate attribute form for attribute
  3384. DW_DLE_ATTR_NO_CU_CONTEXT:No CU context for Dwarf_Attribute struct
  3385. DW_DLE_ATTR_FORM_SIZE_BAD:Size of block in attribute value bad
  3386. DW_DLE_ATTR_DBG_NULL:No Dwarf_Debug for Dwarf_Attribute struct
  3387. DW_DLE_BAD_REF_FORM:Inappropriate form for reference attribute
  3388. DW_DLE_ATTR_FORM_OFFSET_BAD:Offset reference attribute outside current CU
  3389. DW_DLE_LINE_OFFSET_BAD:Offset of lines for current CU outside .debug_line
  3390. DW_DLE_DEBUG_STR_OFFSET_BAD:Offset into .debug_str past its end
  3391. DW_DLE_STRING_PTR_NULL:Pointer to pointer into .debug_str NULL
  3392. DW_DLE_PUBNAMES_VERSION_ERROR:Version stamp of pubnames incorrect
  3393. DW_DLE_PUBNAMES_LENGTH_BAD:Read pubnames past end of .debug_pubnames
  3394. DW_DLE_GLOBAL_NULL:Null Dwarf_Global specified
  3395. DW_DLE_GLOBAL_CONTEXT_NULL:No contect for Dwarf_Global given
  3396. DW_DLE_DIR_INDEX_BAD:Error in directory index read
  3397. DW_DLE_LOC_EXPR_BAD:Bad operator read for location expression
  3398. DW_DLE_DIE_LOC_EXPR_BAD:Expected block value for attribute not found
  3399. DW_DLE_OFFSET_BAD:Offset for next compilation-unit in .debug_info bad
  3400. DW_DLE_MAKE_CU_CONTEXT_FAIL:Could not make CU context
  3401. DW_DLE_ARANGE_OFFSET_BAD:Offset into .debug_info in .debug_aranges bad
  3402. DW_DLE_SEGMENT_SIZE_BAD:Segment size should be 0 for MIPS processors
  3403. DW_DLE_ARANGE_LENGTH_BAD:Length of arange section in .debug_arange bad
  3404. DW_DLE_ARANGE_DECODE_ERROR:Aranges do not end at end of .debug_aranges
  3405. DW_DLE_ARANGES_NULL:NULL pointer to Dwarf_Arange specified
  3406. DW_DLE_ARANGE_NULL:NULL Dwarf_Arange specified
  3407. DW_DLE_NO_FILE_NAME:No file name for Dwarf_Line struct
  3408. DW_DLE_NO_COMP_DIR:No Compilation directory for compilation-unit
  3409. DW_DLE_CU_ADDRESS_SIZE_BAD:CU header address size not match Elf class
  3410. DW_DLE_ELF_GETIDENT_ERROR:Error in elf_getident() on object
  3411. DW_DLE_NO_AT_MIPS_FDE:DIE does not have DW_AT_MIPS_fde attribute
  3412. DW_DLE_NO_CIE_FOR_FDE:No CIE specified for FDE
  3413. DW_DLE_DIE_ABBREV_LIST_NULL:No abbreviation for the code in DIE found
  3414. DW_DLE_DEBUG_FUNCNAMES_DUPLICATE:Multiple .debug_funcnames sections
  3415. DW_DLE_DEBUG_FUNCNAMES_NULL:No data in .debug_funcnames section
  3416. .TE
  3417. .FG "List of Dwarf 2 Error Codes (contd.)"
  3418. .DE
  3419.  
  3420. .DS
  3421. .TS
  3422. center box, tab(:);
  3423. lfB lfB
  3424. l l.
  3425. SYMBOLIC NAME:DESCRIPTION
  3426. _
  3427. DW_DLE_DEBUG_FUNCNAMES_VERSION_ERROR:Version stamp in .debug_funcnames bad
  3428. DW_DLE_DEBUG_FUNCNAMES_LENGTH_BAD:Length error in reading .debug_funcnames
  3429. DW_DLE_FUNC_NULL:NULL Dwarf_Func specified
  3430. DW_DLE_FUNC_CONTEXT_NULL:No context for Dwarf_Func struct
  3431. DW_DLE_DEBUG_TYPENAMES_DUPLICATE:Multiple .debug_typenames sections
  3432. DW_DLE_DEBUG_TYPENAMES_NULL:No data in .debug_typenames section
  3433. DW_DLE_DEBUG_TYPENAMES_VERSION_ERROR:Version stamp in .debug_typenames bad
  3434. DW_DLE_DEBUG_TYPENAMES_LENGTH_BAD:Length error in reading .debug_typenames
  3435. DW_DLE_TYPE_NULL:NULL Dwarf_Type specified
  3436. DW_DLE_TYPE_CONTEXT_NULL:No context for Dwarf_Type given
  3437. DW_DLE_DEBUG_VARNAMES_DUPLICATE:Multiple .debug_varnames sections
  3438. DW_DLE_DEBUG_VARNAMES_NULL:No data in .debug_varnames section
  3439. DW_DLE_DEBUG_VARNAMES_VERSION_ERROR:Version stamp in .debug_varnames bad
  3440. DW_DLE_DEBUG_VARNAMES_LENGTH_BAD:Length error in reading .debug_varnames
  3441. DW_DLE_VAR_NULL:NULL Dwarf_Var specified
  3442. DW_DLE_VAR_CONTEXT_NULL:No context for Dwarf_Var given
  3443. DW_DLE_DEBUG_WEAKNAMES_DUPLICATE:Multiple .debug_weaknames section
  3444. DW_DLE_DEBUG_WEAKNAMES_NULL:No data in .debug_varnames section
  3445. DW_DLE_DEBUG_WEAKNAMES_VERSION_ERROR:Version stamp in .debug_varnames bad
  3446. DW_DLE_DEBUG_WEAKNAMES_LENGTH_BAD:Length error in reading .debug_weaknames
  3447. DW_DLE_WEAK_NULL:NULL Dwarf_Weak specified
  3448. DW_DLE_WEAK_CONTEXT_NULL:No context for Dwarf_Weak given
  3449. .TE
  3450. .FG "List of Dwarf 2 Error Codes"
  3451. .DE
  3452.  
  3453. This list of errors is not necessarily complete;
  3454. additional errors
  3455. might be added when functionality to create debugging information 
  3456. entries are added to \fIlibdwarf\fP and by the implementors of 
  3457. \fIlibdwarf\fP to describe internal errors not addressed by the 
  3458. above list.
  3459. Some of the above errors may be unused.
  3460. Errors may not have the same meaning in different implementations.
  3461.  
  3462. .DS
  3463. \f(CWDwarf_Handler dwarf_seterrhand(
  3464.         Dwarf_Debug dbg,
  3465.         Dwarf_Handler errhand)\fP
  3466. .DE
  3467. The function \f(CWdwarf_seterrhand()\fP replaces the error handler 
  3468. (see \f(CWdwarf_init()\fP) with \f(CWerrhand\fP.  The old error handler 
  3469. is returned.  This function is currently unimplemented.
  3470.  
  3471. .DS
  3472. \f(CWDwarf_Ptr dwarf_seterrarg(
  3473.         Dwarf_Debug dbg,
  3474.         Dwarf_Ptr errarg)\fP
  3475. .DE
  3476. The function \f(CWdwarf_seterrarg()\fP replaces the pointer to the 
  3477. error handler communication area (see \f(CWdwarf_init()\fP) with 
  3478. \f(CWerrarg\fP.  A pointer to the old area is returned.  This
  3479. function is currently unimplemented.
  3480.  
  3481. .DS
  3482. \f(CWvoid dwarf_dealloc(
  3483.         Dwarf_Debug dbg,
  3484.         void* space, 
  3485.         Dwarf_Unsigned type)\fP
  3486. .DE
  3487. The function \f(CWdwarf_dealloc\fP frees the dynamic storage pointed
  3488. to by \f(CWspace\fP, and allocated to the given \f(CWDwarf_Debug\fP.
  3489. The argument \f(CWtype\fP is an integer code that specifies the allocation 
  3490. type of the region pointed to by the \f(CWspace\fP.  Refer to section 
  3491. 4 for details on \fIlibdwarf\fP memory management.
  3492.  
  3493. .SK
  3494. .S
  3495. .TC
  3496. .CS
  3497.